I'd like to connect geth by IPC on rails. I start geth as follows.
$build/bin/geth --datadir "/home/vagrant/.ethereum" --networkid "1" --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --ipcpath "/home/vagrant/.ethereum/geth.ipc"
Then I tried to connect from rails console
using ethereum-ruby. However, it returns error. Could you tell me how to connect geth from ruby?(It doesn't matter whether it is used the library or not.
[1] pry(main)> client = Ethereum::IpcClient.new("#{ENV['HOME']}/.ethereum/geth.ipc")
=> #<Ethereum::IpcClient:0x007f4f4365f470
@batch=[],
@id=1,
@ipcpath="/home/vagrant/.ethereum/geth.ipc">
[2] pry(main)> client.eth_coinbase
NoMethodError: undefined method `eth_coinbase' for #<Ethereum::IpcClient:0x007f4f4365f470>
from (pry):2:in `<main>'
Best Answer
You are using the wrong command, the command is
coinbase
, noteth_coinbase
.I suggest to use this code:
This will automatically use the default path to get
geth.ipc
And this will return your coinbase.
You can see that this line, used to create the new method, is not getting the first part of the rpc method name, and, it's underscoring the method, so
eth_coinbase
will becoinbase
,eth_getBalance
will beget_balance
and so on.