Send transactions to Ethereum contracts via JSON RPC API

unic0rnunic0rn Member Posts: 6
I'm playing around with geth and wanted to interacts with contracts through JSON RPC API. However, I'm confused because the TX returned by eth.getTransactionFromBlock() and created by eth.sendTransaction have different fields. Per Ethereum Gitbook, eth.sendTransaction takes in params like this:
params: [{
  "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  "to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
  "gas": "0x76c0", // 30400,
  "gasPrice": "0x9184e72a000", // 10000000000000
  "value": "0x9184e72a", // 2441406250
  "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
All these fields make sense but there is no place to specify the input to the target contract. Using other tools, such as the console and web apps, I can send TXs and noticed the TX takes a form like this:
> eth.getTransactionFromBlock(60)
  blockHash: "0xc386191621e45e170d50c1caacc9090b7117e09d0847c46f77f6a3c822ec5580",
  blockNumber: 60,
  from: "0xd9b56ae6e0f7a7e0e0dec74b685b2c7f3f543472",
  gas: 66666,
  gasPrice: 50000000000,
  hash: "0x28aa9e720e11f2f81490b6500a3a56c19ec77b936fc745d16c302387837f324e",
  input: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000064",
  nonce: 6,
  to: "0x689495d3e1ff1b955bc4d0bde622bdb34dbb787b",
  transactionIndex: 0,
  value: 0
Note the there is an input field.

So, why do transactions have different fields and is it possible to send transactions via JSON RPC API? If so, which API should be used?


Sign In or Register to comment.