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?

eth
  • 85,679
  • 53
  • 285
  • 406
  • See http://ethereum.stackexchange.com/questions/10862/deploying-contract-with-constructor-arguments-via-geth-rpc/10863#10863 . – BokkyPooBah Feb 10 '17 at 19:37

1 Answers1

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.

Prashant Prabhakar Singh
  • 8,026
  • 5
  • 40
  • 79