通过JSON RPC API将交易发送到以太坊合约



我正在玩geth,希望通过JSON RPC API与契约交互。然而,我感到困惑,因为eth.sendTransactionAPI中没有input的位置。

根据以太坊Gitbook,eth.sendTransaction接受如下参数:

params: [{
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
"gas": "0x76c0", // 30400,
"gasPrice": "0x9184e72a000", // 10000000000000
"value": "0x9184e72a", // 2441406250
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]

所有这些字段都有意义,但没有地方指定输入。使用其他工具,如控制台和web应用程序,我可以sendTransaction,并注意到TX的形式如下:

> 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
}

请注意,有一个输入字段。那么,是否可以通过JSON RPC API发送事务?如果是,应使用哪种API?

事务输入由eth_sendTransactionRPC消息的data参数表示。

最新更新