4

My contract has a method with this signature:

register(byte32 documentHash, string owner, string url)

I read this documents (https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector) and tried to execute a transaction using JSON-RPC.

I understand that the data parameter for the eth_sendTransaction method will begin with "0x9b74202e" : first 4 bytes of Keccak encode from "register(byte32,string,string)".

I do not understand how to correctly encode the parameters.

Example:

documentHash = d46046d56d3807a12978ebccfbf0960790bb8d40f3888ac2d5d8416753cd5c54

owner = "johndoe@gmail.com"

url = "https://dl.dropboxusercontent.com/u/96015624/document.pdf"

For this example, how do I encode the data parameter?

1

As I understand your question, you want to get the data parameter used in eth_sendTransaction.

var contract = web3.eth.contract(contractABI).at(contractAddress);
var data = contract.register.getData(d46046d56d3807a12978ebccfbf0960790bb8d40f3888ac2d5d8416753cd5c54, "johndoe@gmail.com",  "https://dl.dropboxusercontent.com/u/96015624/document.pdf");

This will be your data parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.