Operations
In order to interact with other contracts and accounts so-called operations can be emitted.
WARNING
Operations (e.g. sp.transfer
) are collected and executed only after the entrypoint has completed.
This means that changes in e.g. the contract balance are not reflected immediately:
smartpy
@sp.entrypoint
def ep(self, destination):
b = sp.balance
sp.transfer(sp.unit, sp.tez(5), destination)
assert b == sp.balance # sp.balance is unchanged at this point
- sp.transfer(argument: t, amount: sp.mutez, destination: sp.contract[t])
Call the contract at
destination
withargument
while transferringamount
to it.smartpysp.transfer(100, sp.mutez(0), c) sp.transfer(42, sp.mutez(0), sp.self_entrypoint("abc"))
- sp.set_delegate(d: sp.option[sp.key_hash])
Sets the delegate.
smartpysp.set_delegate(d: sp.option[sp.key_hash])
- sp.emit(event: t, tag="...", with_type=[True|False])
Emits
event
as an event, optionally tagged withtag
. Ifwith_type=True
is given the type ofevent
is explicitly given in the compiled Michelson code.Examples:
smartpysp.emit("Hello") sp.emit("World", tag="mytag") sp.emit(sp.record(a="ABC", b="XYZ"), tag="mytag2", with_type=True)