TransWikia.com

in smartpy, local variable param, what's difference?

Tezos Asked by MS.J on January 6, 2021

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.

One Answer

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"

Answered by Rodrigo Quelhas on January 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP