in smartpy

def aa(self) {
    value_in_func = "1234"
    msg = "abc" + value_in_func
    hex_string = msg.encode("utf-8")
    thingToSign = sp.bytes("0x" + hex_string.hex())

This is working well, But

value = "1234"
def aa(self, value)
    msg = "abc" + value
    hex_string = msg.encode("utf-8")
    thingToSign = sp.bytes("0x" + hex_string.hex())

is NOT working. Error: call() missing 1 positional argument: arg

I don't know the difference between the two.

what's difference?

I checked sp.verify(value_in_func == value), this is true.

  • You have two different things called value in your second example...
    – FFF
    Sep 28, 2020 at 10:31
  • The consequence is that you’re trying to call encode on a SmartPy expression.
    – FFF
    Sep 28, 2020 at 16:35

1 Answer 1


The reason for the error is that you are not passing a parameter to the method:

Your test should contain something like this

    c1 = YourContract(...)
    scenario += c1
    scenario += c1.aa("1234")

And remove the value = "1234"

Your Answer

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

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