ESP32 Web3 status: failed [execution reverted]

Hi everyone !

Deployed this smart contract on Sepolia Testnet

//SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.8.2 <0.9.0;

contract SmartContractDeployment {
    uint256 number; 

    event Log(string message);

    receive() external payable {}

    function store(uint256 num) public {
        emit Log("new number stored");
        number = num;
    }

    function retrieve() public view returns (uint256){
        return number;
    }
}

I have sent 0.1Eth on it just to make sure. Now I wanted to send transaction to trigger the function on smart contract. The code is below

void SendTransToContract(const char *contractAddr)
{
    // Generate contract instance. Pass contract address as 2nd parameter.
    Contract contract(web3, SETUPCONTRACT);

    // Set your secret to contract.
    // This secret will not send to server (of course!) but use locally to sign.
    contract.SetPrivateKey(PRIVATE_KEY);
    string address = MY_ADDRESS;

    // Get nonce with web3->EthGetTransactionCount() API
    uint32_t nonceVal = (uint32_t)web3->EthGetTransactionCount(&address);
    unsigned long long gasPriceVal = 2200000000LL;
    uint32_t gasLimitVal = 3000000;
    string toStr = SETUPCONTRACT;
    uint256_t valueStr = 0x00;
    uint8_t dataStr[100];
    memset(dataStr, 0, 100);
    Serial.println(nonceVal);
    // Generate binary data to send contract.
    // In this case, generate data to send to "store(uint256)" and use "123" as the first parameter.
    contract.SetupContractData((char*)dataStr, "store(uint256)", 123);

    // Convert dataStr to std::string
    std::string dataString(reinterpret_cast<char*>(dataStr));

    // send transaction
    string result = contract.SendTransaction(nonceVal, gasPriceVal, gasLimitVal, &toStr, &valueStr, &dataString);
    Serial.println(result.c_str());
	  string transactionHash = web3->getResult(&result);

    Serial.println("TX on Etherscan:");
	  Serial.print(ETHERSCAN_TX);
	  Serial.println(transactionHash.c_str()); 
}

It basically works and i receive this

359
67
{"jsonrpc":"2.0","id":0,"result":"0x8b87b429bcdbbbe68f5c93422c2d64f564670c5b00864009a15c5be8e6e58541"}

0


TX on Etherscan:
https://sepolia.etherscan.io/tx/8b87b429bcdbbbe68f5c93422c2d64f564670c5b00864009a15c5be8e6e58541

However the transaction doesn’t pend and fails for unknown reason.

Could you help me please :pray:

Hi @hmmmmm324

It looks like the transaction did not fail on the chain as etherscan says it is an invalid transaction hash.

Maybe the transaction failed with some other reason before sending it to the blockchain. Do you see any other errors on your node console.