Skip to content
On this page

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 with argument while transferring amount to it.

smartpy
sp.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.

smartpy
sp.set_delegate(d: sp.option[sp.key_hash])
sp.emit(event: t, tag="...", with_type=[True|False]) → 

Emits event as an event, optionally tagged with tag. If with_type=True is given the type of event is explicitly given in the compiled Michelson code.

Examples:

smartpy
sp.emit("Hello")
sp.emit("World", tag="mytag")
sp.emit(sp.record(a="ABC", b="XYZ"), tag="mytag2", with_type=True)