1

I have geth running on my server. I am building a php website which act as wallet. Now iam able to create addresses. I need to be able to deposit and withdraw ETH between addresses on same node. I start geth with below command.

go-ethereum/build/bin/geth console  --rpc --rpcapi="db,eth,net,web3,personal,web3" --rpccorsdomain "*" --syncmode "light"

How to acheive the functionality of a wallet on geth over rpc ? Is there a command or API call for that? Iam finding it hard to understand the documentation.

UPDATE: What I want to do is transfer ETH from one account to another. Below are the api calls i tried and the errors I got in the browser when i call transfer function in my php class. Can someone please correct me

{"jsonrpc":"2.0","id":1,"method":"personal_signAndSendTransaction","params":[[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}],"passphrase"]}

Fatal error: Uncaught RPCException: json: cannot unmarshal array into Go value of type eth.SendTxArgs

{"jsonrpc":"2.0","id":1,"method":"personal_sendTransaction","params":[[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}],"passphrase"]}

Fatal error: Uncaught RPCException: The method personal_sendTransaction does not exist/is not available thrown

{"jsonrpc":"2.0","id":1,"method":"eth_sendTransaction","params":[{"from":"0xb60e8dd61c5d32be8058bb8eb970870f07233155","to":"0xd46e8dd67c5d32be8058bb8eb970870f07244567","gas":"0x76c0","gasPrice":"0x9184e72a000","value":"0x9184e72a","data":"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}]}

Fatal error: Uncaught RPCException: account is locked thrown

Please help!

4
  • do not use eth_sendTransaction, you are going to have to unlock the account and that's insecure. Your users are going to be hacked and you are going to be hated. Ese eth_sendRawTransaction and sign transaction before sending it, with javascript . Your best example is myphpwallet, download the sources and just copy all the process of signing transaction and youre done
    – Nulik
    Feb 27, 2018 at 13:09
  • can you please send a link to myphpwallet
    – SMJ
    Feb 27, 2018 at 13:17
  • sorry, it is myetherwallet, not myphpwallet
    – Nulik
    Feb 27, 2018 at 14:59
  • download chrome extension
    – Nulik
    Feb 27, 2018 at 14:59

2 Answers 2

2

In Geth console, you can use the sendTransaction function :

web3.eth.sendTransaction({
    from: "0xE618A4B5A516f371Ce26d9A1DBE7839F4e3812GB",
    to: "0xE618A4B5A516f371Ce26d9A1DBE7839F4e3812CB",
    value: web3.toWei(1, "ether")
})
1
  • I want to interact with geth from my browser using json rpc. Is there a method to convert 1 etc to 'web3.toWei(1, "ether")})' format that i can pass ?
    – SMJ
    Mar 16, 2018 at 6:09
1

You can use eth_sendtransaction to send a transaction to the destination

In the params section

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

You should get back a transaction signature

{
    "id":1,
    "jsonrpc": "2.0",
    "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

This works on accounts that have been unlocked in geth previously

13
  • if i have an address, I want to add 1 ETC to that address, How can I do that?
    – SMJ
    Feb 27, 2018 at 11:11
  • can you show an example?
    – SMJ
    Feb 27, 2018 at 11:11
  • can we send ether to an address outside of my network?
    – SMJ
    Feb 27, 2018 at 11:15
  • You need to buy some Ether, send them to the account that is unlocked in the geth client and you should be able to send fractions of that Ether to other adresses. Feb 27, 2018 at 11:44
  • What does "outside of your network" mean? How do you define your network? You can send Ether to any address. Even if the address does not exist. Feb 27, 2018 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.