I'm trying to create a contract using the JSON RPC. I understand how it's done in general (pass the contract's code as the 'data' parameter), but what if I'd like to pass additional parameters to the contract's constructor?
Here's my code:
contract Asset {
... some code here ..
function Asset(string _name, uint _supply) {
tokenName = _name;
... more code here ...
}
...
The question, then, is how do I use the JSON-RPC eth_sendTransaction
to pass the _name and _supply arguments to the constructor of 'asset'.
0 ·
Comments
we call a function : register(bytes32 hash, bytes32 date) via JSON RPC. The data element is 0x<32 characters for first parameter "hash"><32 characters for second parameters "date">. We debugged the cosmo meteor client :-)
ciao Frank
it's 0x, then 8 characters hash of function signiture (in our case register(bytes32 hash, bytes32 date)), then 32... see above
ciao Frank
Would someone be able to post a sample JSON string that would invoke a method on an existing contract in the public block-chain (and return a valid result)? Also, I am not sure if I am calculating my function hash correctly (I am currently using geth's own web3_sha3 method - really slow and inefficient - would like a native .Net equivalent).
If I am successful with this .Net wrapper, I will post it to the community. Unless there is already something similar out there, I would be very happy to hear!
Thank you all!
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcontract
e.g.:
var contractData = MyContract.new.getData([contructorParam1] [, contructorParam2], {data: '0x12345...'});
Same logic as with functions, but as first parameter should be given full contract code.