Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error calling smart contract functions with parameters #26

Open
RodrigoRP7 opened this issue Sep 28, 2023 · 1 comment
Open

Error calling smart contract functions with parameters #26

RodrigoRP7 opened this issue Sep 28, 2023 · 1 comment

Comments

@RodrigoRP7
Copy link

Hi!

Thanks for your awesome work, your library is great and has saved me lots of time and headaches.

I am using it with an ESP32 WROOM and I've been able to: 1) Send transaction to address 2) Call smart contract functions 3) Send transactions to smart contract functions without parameters.

However, I get an error every time I try to send a transaction to a smart contract function that contains some arguments. Here is an example:

Working

C++ code

string param = contract.SetupContractData("modifyNumber()"); 
string result = contract.SendTransaction(nonceVal, gasPriceVal, gasLimitVal, &contractAddrStr, &callValue, &param);

Solidity code

contract Test {

    uint8 public number = 20;

    function modifyNumber() public {
        number = 100;
    }

}

Not working

C++ code

uint8_t newNum = 100;
string param = contract.SetupContractData("modifyNumber(uint8)", &newNum); 
string result = contract.SendTransaction(nonceVal, gasPriceVal, gasLimitVal, &contractAddrStr, &callValue, &param);

Solidity code

contract Test {

    uint8 public number = 20;

    function modifyNumber(uint8 newNum) public {
        number = newNum;
    }

}

Error

The error occurs in contract.SetupContractData(...), whenever the provided function contains some parameters.
The output error is of type:
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled

Thank you in advance!

@RodrigoRP7
Copy link
Author

I just found out that the SetupContractData() function does not interpret uint parameters with size different than 256 bits. In my case, I was trying to pass a uint8, but this is not defined in the library function. Maybe this could be an interesting upgrade to allow optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant