以太坊系列六:JsonRPC操作以太坊转账的快捷方式

一、以太币的标准转账快捷方式,命令rpc调用方式参照如下:

$curl localhost:8545 -H "Content-Type:application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0x7ae692cd90238a43732a485f1814b51099227422",  "to": "0xfe49f3e408fc93d11663c3ec867e732ba4b15a4f",  "gas": "0x76c0",   "gasPrice": "0x9184e72a000",   "value": "0x9184e72a","data":"0x23b872dd0000000000000000000000007ae692cd90238a43732a485f1814b51099227422000000000000000000000000fe49f3e408fc93d11663c3ec867e732ba4b15a4f000000000000000000000000000000000000000000000000000000009184e72a"}],"id":1}'

curl localhost:8545 -H "Content-Type:application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0x7ae692cd90238a43732a485f1814b51099227422",  "to": "0xfe49f3e408fc93d11663c3ec867e732ba4b15a4f",  "gas": "0x76c0",   "gasPrice": "0x9184e72a000",   "value": "0x9184e72a","data":"0x23b872dd0000000000000000000000007ae692cd90238a43732a485f1814b51099227422000000000000000000000000fe49f3e408fc93d11663c3ec867e732ba4b15a4f000000000000000000000000000000000000000000000000000000009184e72a"}],"id":1}'

说明:

1、本调用前需要确保from地址对应的帐号已经解锁(可在console中输入命令:personal.unlockAccount(“0x7ae692cd90238a43732a485f1814b51099227422”) ,并按提示输入密码进行解锁)。

2、本调用需要特别关注的地方在于params中的data字段的拼凑规则:

“0x”+"23b872dd"+"from地址去掉0x并由0补够64位数"+"to地址去掉0x并由0补够64位数"+"十六进制的value值去掉0x并由0补够64位数"

其中"23b872dd"为以太坊标准转账合约中转账功能函数对应的十六进制码。

3、对于自编写的智能合约的调用,data字段可以直接填写合约代码编译出来的abi内容。

 

 

你可能感兴趣的:(以太坊)