Skip to main content

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)

​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)

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