Skip to content
On this page

Michelson code inlining โ€‹

See reference Inline Michelson template.

Methods โ€‹

michelson โ€‹

Inline arbitrary Michelson code.

types_in and types_out are lists of types, and code is some Michelson code using the micheline syntax.

Currently, in practice, only singleton types_out are supported.

sp.michelson(code, types_in, types_out)

python
self.data.x = sp.michelson("ADD;", [sp.TInt, sp.TInt], [sp.TInt])(15, 16)
self.data.y = sp.michelson("DUP; DIG 2; ADD; MUL;", [sp.TInt, sp.TInt], [sp.TInt])(15, 16)

lambda_michelson โ€‹

A special case of sp.michelson where the code represents a lambda.

sp.lambda_michelson(code,ย sourceย =ย None,ย targetย =ย None)

It is of type sp.TLambda(type_in, type_out)

python
self.data.f = sp.lambda_michelson("DUP; PUSH int 2; ADD; MUL;", sp.TNat, sp.TInt)