kopanitsa / web3-arduino

an Arduino (or ESP32) library to use web3 on Ethereum platform.
MIT License
106 stars 46 forks source link

No data sent to the smart contract #15

Closed phoax closed 6 years ago

phoax commented 6 years ago

Hello,

I am trying to send a transaction on an Infura Ropsten node. The transaction is executed, but the value is empty.

The code is:

// transaction
    string contract_address = "0xc4edaebde3a6fc825a2f3eadae69e5db93e6e967";
    Contract contract(&web3, &contract_address);
    contract.SetPrivateKey(privateKey);
    string address = "0x3d355bcdF4d712861E7Dad907Ca1F3509F511A88";
    uint32_t nonceVal = (uint32_t)web3.EthGetTransactionCount(&address);

    uint32_t gasPriceVal = 141006540;
    uint32_t  gasLimitVal = 3000000;
    string toStr = "0xc4edaebde3a6fc825a2f3eadae69e5db93e6e967";
    string valueStr = "0x00";

    string func = "set(uint256)";
    string p = contract.SetupContractData(&func, 123);
    string result = contract.SendTransaction(nonceVal, gasPriceVal, gasLimitVal, &toStr, &valueStr, &p);

The result is: https://ropsten.etherscan.io/tx/0x1fddb5d20e587f349af7175d4bdb9e55db174fe3373a4f84201446b5ae018937

How can I send 123 to the smart contract ?

Thanks,

phoax commented 6 years ago

this solve my problem https://github.com/kopanitsa/web3-arduino/pull/14