- sp.cast(x, T) → T
For a given value
xand a type
T. This can be used to fix the type of an expression. Often this is done for parameters of entrypoints and in order to resolve type ambiguities:smartpy
@sp.entrypoint def ep(x, y): sp.cast(x, sp.int) ...
Note that this expression can be used both as a statement and as an expression, e.g. one can also write:smartpy
r = sp.cast(x, sp.int) + 1