Skip to content
On this page

Returning and binding data โ€‹

This is an advanced topic and need not be looked at for regular SmartPy developers.

In a block, we can write sp.result(expr) to compute expr and prepare the local result. This data can be bound by using sp.bind_block().

See reference Bind template.

In this example, we define a block b, computes some value and return it.

python
def f(self, params)
    b = sp.bind_block()
    with b:
        sp.if params > 12:
            sp.result(self.data.x + params)
        else:
            sp.result(self.data.x + 2)
    return b.value