When calling a method that uses a local variable twice, I'm getting this error.

Example smartpy link. In this linked code I added a new method test_string_of_nat2 which triggers this behavior.

How should this type of function be called if it's needed more than once within the same entry point?

1 Answer 1


You can use the sp.private_lambda decorator.

  • Thanks! That worked for this example. Though, when using it on an off_chain_view I'm getting the error Missing private variable string_of_nat Is it not possible to use within off_chain_views? What could I do if I want to use them here? smartpy.io/…
    – JJJ
    Commented Feb 14, 2022 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.