Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Blockchain by (12.7k points)

'm learning ethereum blockchain with Ruby and using this library:

https://github.com/EthWorks/ethereum.rb

I follow the guide and use the file greeter.sol here:

https://github.com/marekkirejczyk/ruby_ethereum_example/blob/master/contracts/greeter.sol

But I always got this error:

invalid argument 0: json: cannot unmarshal non-string into Go struct field SendTxArgs.from of type common.Address

This is my current code:

contract = Ethereum::Contract.create file: File.join(File.dirname(__FILE__), '../contracts/greeter.sol')

address = contract.deploy_and_wait("Hello from ethereum.rb!")

Anyone can help me, I'm very new to this. Thanks.

1 Answer

0 votes
by (29.5k points)
edited by

Hi, you should specify the default_account for client(sender address).

Something like this:

client = Ethereum::IpcClient.new("your path to .ipc", true)
client.default_account = '0xa9db3f4efe....

then

contract = Ethereum::Contract.create( abi: abi, name: name, client:client, address: address)

Know the blockchain better through Blockchain Certification by Intellipaat.

Browse Categories

...