中国比特币交易手续费,中国个人比特币交易,以太坊rpc钱包

2021/05/19 16:07 · 数字货币 ·  · 0评论

中国比特币交易手续费,中国个人比特币交易,以太坊rpc钱包

接着发存货。。。以下是制作以太坊系列钱包常用的rpc接口调用事例

0.以太坊安装:
1)构建:

sudo apt-get install software-properties-common

sudo add-apt-repository -y ppa:ethereum/ethereum

sudo apt-get update

sudo apt-get install ethereum

2)控制台启动:
geth —identity “maimai2018” //自定义节点身份名称
—datadir “/root/geth/test” //区块储同步的信息等存的位置,账户秘钥文件keystore也存储在此处
—rpc —rpccorsdomain “*” //开启rpc接口
—port “8090” //节点的端口
—rpcapi “db,eth,net,web3,personal,admin,miner” // 节点的方法库,personal为解锁加锁账户需要,一般都开启
—rpcaddr “0.0.0.0” //rpc允许外部所有ip
—rpcport “8111” //rpc http端口
—testnet //测试网
console //打开控制台

指令综合:

geth --identity "chainwang2018"  --datadir "/root/geth/test"  --rpc --rpccorsdomain "*" --port "8090" --rpcapi "db,eth,net,web3,personal,admin,miner"  --rpcaddr "0.0.0.0" --rpcport "8111" --testnet  console

3)挂至后台输出日志:

nohup geth --identity "chainwang2018"  --datadir "/root/geth/test"  --rpc --rpccorsdomain "*" --port "8090" --rpcapi "db,eth,net,web3,personal,admin,miner"  --rpcaddr "0.0.0.0" --rpcport "8111" --testnet >> /home/geth.log

ps:以太坊输出或者输入的数字都是16进制的,数字和账户的前缀为0x(零X)开头,数字解析时去掉0x,然后转换成十进制即可。

HTTP POST请求
端口: ip:8111
其他jsonRPC参考网址:https://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-methods

1.创建账户:
请求:

{

"jsonrpc":"2.0",

"method": "personal_newAccount",

"params": ["wangyaxing"],  //账户密码

"id":1}

输出:

{

"jsonrpc": "2.0",

"id": 1,

"result": "0x0466d7316d681b9646f3b766aa3872a182a6c557"   //公钥地址

}

PS:输出的钱包位置,在服务器中为:

2.监控交易:

监控交易时,写循环从某个高度开始跑,定时高度逐步增加,获取里面的交易,得到我们钱包账户的交易信息。

1)查询区块高度
请求:

{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}

输出:

{

"jsonrpc": "2.0",

"id": 1,

"result": "0x3eea49"  //此处为区块高度(去掉0X前缀,16进制的返回结果转换为十进制)

}

2)通过区块高度,获取当前区块高度内的所有交易
请求:

{"jsonrpc":"2.0",

"method":"eth_getBlockByNumber",   //方法

"params":[

"0x1b4444",    //查询的区块高度

true

],

"id":1

}

输出:

{

"jsonrpc": "2.0",

"id": 1,

"result": {

"difficulty": "0x46a6992a9",

"extraData": "0x526f707374656e20506f6f6c2042797a616e7469756d",

"gasLimit": "0x6acfc0",

"gasUsed": "0x6a7080",

"hash": "0x2400fbdf20d4e9933b486064b9548dfd6f31dae56f3b59404f5298126aaedb30",

"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",

"miner": "0xf4d8e706cfb25c0decbbdd4d2e2cc10c66376a3f",

"mixHash": "0xeb87a854fc1f6535b021b50df367bd44da3a73680436fc736d3631b05d488c4e",

"nonce": "0x21c07165011475e5",

"number": "0x1b4456",

"parentHash": "0xd91e76563e6c85a6e564d6d279cb19719504d08035970b2e89404b69ead90f6e",

"receiptsRoot": "0xcda7b6a4229f59c262b09172b822878a4512bd7e9650000d73a9359662175337",

"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",

"size": "0x3c2",

"stateRoot": "0x1800f6b4850fac7570b2e6ee67abff36a29a07f3a1d3d562ed589ecf3130ba76",

"timestamp": "0x59d16b05",

"totalDifficulty": "0xc04129639959e",

"transactions": [

{

"blockHash": "0x2400fbdf20d4e9933b486064b9548dfd6f31dae56f3b59404f5298126aaedb30",

"blockNumber": "0x1b4456",

"from": "0x7075355043c6af2d36c7b056f5daa5b02a9e283f",//从哪个账户转

"gas": "0x4cb26",      //gas的数量

"gasPrice": "0x45d964b800",//gas的单价    gas和gasPrice相乘为消耗的转账费用,单位为wei

"hash": "0x632ef6aea8eb203473cb90b6eec92639f6508dea7202aaf3a52bffadd776d9a1",  ////交易hash

"input": "0x",

"nonce": "0x6d",

"to": "0xe143b3e8646e5ccb3462aba805f1e7a019171cb4",  //收账账户

"transactionIndex": "0x0",

"value": "0x16345785d8a0000",

"v": "0x1b",

"r": "0xd63c79c65b02a0bfedaa8c0b6bc41ac1497677a4311b465399034afce8a58981",

"s": "0x364cab16e02688b930c8d119ae8da51577f69fcb73713c62ab1fa83a6ba83370"

},

{

"blockHash": "0x2400fbdf20d4e9933b486064b9548dfd6f31dae56f3b59404f5298126aaedb30",

"blockNumber": "0x1b4456",

"from": "0x04ccc070c6007b2b422ab4b52bda60d5d8693abf",

"gas": "0x3567e0",

"gasPrice": "0x2e90eddabf",

"hash": "0xb39d1448f1224612dbcd22ec3fd02dfa6dd5c5a476238d2219c0cb5cb369c3c7",

"input": "0x60606040525b6f604060005360016000f30000000000006000525b602060106001f05061c3505a11601a575b600a8060376000396000f360606040526008565b00",

"nonce": "0x67ce",

"to": null,

"transactionIndex": "0x1",

"value": "0x100000",

"v": "0x29",

"r": "0xeabba9f6b6b06e9b38d6de1597f15275d3cb057e979eed1ccacdf304d00353f9",

"s": "0x4961544f44ff8f1b55320ee912f8a8c75b1b067cb1b3806c2667d2593f733eb5"

},

{

"blockHash": "0x2400fbdf20d4e9933b486064b9548dfd6f31dae56f3b59404f5298126aaedb30",

"blockNumber": "0x1b4456",

"from": "0x04ccc070c6007b2b422ab4b52bda60d5d8693abf",

"gas": "0x3567e0",

"gasPrice": "0x2e90eddac0",

"hash": "0x0df4befcdc49de8091e7063812a21f1af65190d433bd292b0503d58e0832f30a",

"input": "0x60606040525b6f604060005360016000f30000000000006000525b602060106001f05061c3505a11601a575b600a8060376000396000f360606040526008565b00",

"nonce": "0x67cf",

"to": null,

"transactionIndex": "0x2",

"value": "0x100000",

"v": "0x29",

"r": "0x23c3c7c1c9f1afc57e6c983129d8dbf52d33b4af50df08d24cadf919136d18d7",

"s": "0x47cabe6731569c9b7a5c83ff0a1f648d79280af42f078ad788c2c5ba5e8c24b5"

}

],

"transactionsRoot": "0x44d58320d7bb0d336974af67ec6bc851e53d7f27e75e08cd6c64537f7828bf0a",

"uncles": []

}

}

3.交易:

1)解锁账户:

{"jsonrpc":"2.0",

"method": "personal_unlockAccount",   //解锁钱包方法名

"params": [

"0xf6833150d714baabbd7e5768c5f7b200ac180594",   //钱包账户

"wangyaxing",                                    //钱包密码

30         //解锁时间

],

"id":1}

输出:

{

"jsonrpc": "2.0",

"id": 1,

"result": true   //返回true解锁成功

}

2)交易:

{

"jsonrpc":"2.0","method":"eth_sendTransaction",

"params":[{

"from": "0xf6833150d714baabbd7e5768c5f7b200ac180594",  //转账账户公钥

"to": "0x7e95b67a2f91ddd2e3225745598bcf38ca9a9d5c",    //接受账户公钥

"gas": "0x76c0",     //gas的数量

"gasPrice": "0x9184e72a000",//gas的单价

"value": "0x9184e72a",     //转账金额,单位为wei

"data": ""        //转账附带的信息

本文地址:http://www.v777v.com/59.html
文章标签:
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

文件下载

老薛主机终身7折优惠码boke112

上一篇:

 发表评论


表情