1

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.

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

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, privacy policy and cookie policy

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