0

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.

1

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"}.

0

The reason you're getting that error is that you need to have all your param labels and values in quotes (e.g. from -> "from").

Examples:

echo '{"jsonrpc":"2.0","method":"personal_unlockAccount","params": ["0xfe009812bcb5d159dd52b5dab638bbe1ca480571" ,"test",0],"id":1}' | nc -U "$COMMUNITY_DATA_PATH/geth.ipc"


echo '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0xfe009812bcb5d159dd52b5dab638bbe1ca480571", "to": "0xdfe5443654725f409ecc47c2beeae1619ad50bf3", "value": "0x1", "data": "0x010203040506070809", "gas": "0x100000"}],"id":1}'  | nc -U "$COMMUNITY_DATA_DIR/geth.ipc"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy