1

I'm trying to invoke a method with parameters that do nothing (blank body) in a smart contract but that doesn't work even if the contract is correctly deployed to the blockchain.

Use case: Smart contract contains a method:

# params :  sp.record(a = 3, b = 6, c = 9)
methodToBeCalled(self, params)

When I try to create a test scenraio in the smart contract methodToBeCalled(a: 3, b: 6, c: 9) I got this error:

Error: Error in Scenario  Type Error  sp.TRecord(a = sp.TIntOrNat, b = sp.TIntOrNat) is not sp.TUnit  Bad params type sp.record(a: 3, b: 6, c: 9)

So Is it possible to create a method that don't use it's parameters (blank method) just like:

@sp.entry_point
    def Amethod(self, params):
    # params type is record: {a: 3, b: 6, c: 9}
    return

Thank you in advance.

1

As said on telegram, you need to put a type constraint. Otherwise, params is inferred to be of type unit. You can use the command:

sp.set_type(params, sp.TRecord(a = sp.TIntOrNat, b = sp.TIntOrNat)).

| improve this answer | |
  • Yep, thank you. – Daly Feb 6 at 14:10

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.