简体   繁体   English

以太坊如何与RPC交易?

[英]Ethereum how to transaction with rpc?

I start geth client localhost, enter console, unlock account and send transaction. 我启动geth客户本地主机,进入控制台,解锁帐户并发送交易。 web3.personal.unlockAccount("0xe3d787588f28542a5938ca97cc1d6acb9278176d"); eth.sendTransaction({ from: eth.coinbase, to: "0xfbccf3222a38a145c955aaf8ac2c66c6270dac04", value: web3.toWei(1, "ether"), gas: 21000 });

enter image description here 在此处输入图片说明

Need to unlock account with input password, and pravite key save in keystore. 需要使用输入的密码来解锁帐户,并且将Pravite密钥保存在密钥库中。

Json-rpc docs send transaction without password and private key. Json-rpc文档发送没有密码和私钥的交易。

{"jsonrpc"=>"2.0", "id"=>2, "error"=>{"code"=>-32000, "message"=>"authentication needed: password or unlock"}}

Return the error message. 返回错误信息。 But I cannot found how to unlock account, because jsonrpc disable personal function. 但是我找不到如何解锁帐户的方法,因为jsonrpc禁用了个人功能。

Anyhow to send transaction without local geth node? 在没有本地geth节点的情况下如何发送交易?

1.first you should enable geth with --rpcapi "eth,web3,personal" 2.then 1.首先,您应使用--rpcapi“ eth,web3,personal”启用geth 2.然后

curl http://localhost:8545 -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, / ' -H 'Cache-Control: no-cache' -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0xaddress", "password", 15],"id":67}' curl http:// localhost:8545 -H'内容类型:application / json; charset = UTF-8'-H'接受:application / json,text / plain, / '-H'缓存控制:无缓存'-X POST --data'{“ jsonrpc”:“ 2.0”,“ method”:“ personal_unlockAccount”,“ params”:[“ 0xaddress”,“ password”,15],“ id”:67}'

finally you can use rpc to send eth 最终您可以使用rpc发送eth

You can unlock via console like @chuixue explained above or you can also start your geth node with your account unlocked adding these params: 您可以通过上述@chuixue这样的控制台进行解锁,也可以通过解锁帐户添加以下参数来启动geth节点:

./geth -unlock "0xe3d787588f28542a5938ca97cc1d6acb9278176d" --password ./password.txt 

where password.txt contains the password for that account. 其中password.txt包含该帐户的密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM