[Ethereum] Sending Transactions via RPC or IPC

go-ethereumipcjson-rpcprivate-blockchaintransactions

Recently i'm trying to comunicate to a private Ethereum blockchain via RPC/IPC to create a Transaction but what i'm seeing is that i cannot do it via RPC because:
– i Always need to unlock my account before and i cannot do it via RPC :

curl 127.0.0.1:8545  -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params": ["0xWALLET" ,"",null],"id":1}'
{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"The method personal_unlockAccount does not exist/is not available"}} 
  • i see that there is an alternative via IPC so i tried:

    echo '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' | nc -U /path/datadir/geth.ipc 3ef {"jsonrpc":"2.0","id":1,"result":["0xWALLET1","0xWALLET2"]}

Ok so IPC works fine now i try to make a TX:

echo '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{ from: "0xWALLET1", to: "0xWALLET2", value: 1000000000000000000, data: "0x10", gas: 1000000}],"id":1}' | nc -U /path/datadir/geth.ipc
{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character 'f' looking for beginning of object key string"}}

I tried to mess around with params and follow the JSON format
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction

But still i can't figure out how to make this transaction correctly.

Best Answer

To use personal.unlock API through RPC you need to enable it from command line --rpcapi. An example from here: How can I make new account by JSON-RPC?: geth --rpc --rpcapi "db,eth,net,web3,personal".

For IPC to work try using "" for the value and gas { from: "0xWALLET1", to: "0xWALLET2", value: "1000000000000000000", data: "0x10", gas: "1000000"}.