templates.sub_entrypoint
1import smartpy as sp 2 3 4@sp.module 5def main(): 6 class MyContract(sp.Contract): 7 def __init__(self, alice, bob): 8 self.data.x = 2 9 self.data.y = "aaa" 10 self.data.z = 0 11 self.data.alice = alice 12 self.data.bob = bob 13 14 @sp.private(with_storage="read-write", with_operations=True) 15 def a(self, params): 16 sp.cast(params, sp.nat) 17 sp.send(self.data.alice, sp.mul(params, sp.tez(1))) 18 sp.send(self.data.bob, sp.tez(2)) 19 self.data.x += 1 20 return params * self.data.x 21 22 @sp.entrypoint 23 def f(self): 24 self.data.z = self.a(10) + self.a(5) 25 26 @sp.entrypoint 27 def g(self): 28 self.data.z = self.a(6) 29 30 31alice = sp.test_account("alice").address 32bob = sp.test_account("bob").address 33 34 35@sp.add_test() 36def test(): 37 scenario = sp.test_scenario("Sub", main) 38 c1 = main.MyContract(alice, bob) 39 c1.set_initial_balance(sp.tez(1000)) 40 scenario += c1 41 c1.f() 42 scenario.verify(c1.data == sp.record(x=4, z=55, y="aaa", alice=alice, bob=bob))
alice =
(("templates/sub_entrypoint.py" 31) attr (("templates/sub_entrypoint.py" 31) account_of_seed "alice") "address")
bob =
(("templates/sub_entrypoint.py" 32) attr (("templates/sub_entrypoint.py" 32) account_of_seed "bob") "address")