IMPORTANT
My final goal is receive data via api on a php server and use Infura to call my contract to save the data
Test Situation
having this test contract on rinkeby
contract test008 {
mapping (uint256 => string ) private storedData;
function set(uint _index, string memory _data_to_store) public {
storedData[_index] = _data_to_store;
}
function get(uint _index) public view returns (string memory) {
return storedData[_index];
}
}
What's the right syntax to call
set(100, 'hello world')
??
Using curl
, How can I pass the data using the -d
option?
curl https://rinkeby.infura.io/v3/<project_id>\
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_call","params": [ { "to":"hex_address_of_my_contact", "data" : " ?????? " }, "latest" ]}
I must specify eth address of contract in the to
, right?
I must specify name of function, but how ?
And then I must pass parameters, but ... how ?
From the doc of eth_call function
data
: [optional] Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI
Is this data
param the place where specify function name and parameters for the call? If yes.... how ?!
Core question
if all is really about the data param .... ....
Can I generate data hash having function name and parameters? How? Is there any doc about how to do this encoding ? Better: do you know encoding php library?