无法将非字符串解组为类型为common.Address的Go结构字段SendTxArgs.from

问题描述 投票:1回答:1

我正在学习使用Ruby的以太坊区块链并使用这个库:

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

我按照指南使用文件greeter.sol:

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

但我总是遇到这个错误:

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

这是我目前的代码

contract = Ethereum::Contract.create file: File.join(File.dirname(__FILE__), '../contracts/greeter.sol')
address = contract.deploy_and_wait("Hello from ethereum.rb!")

任何人都可以帮助我,我对此很陌生。

谢谢。

ruby blockchain ethereum geth parity-io
1个回答
4
投票

可能你应该为default_account指定client(sender address)

在我的情况下,我已经以这种方式添加它:

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

然后

contract = Ethereum::Contract.create( abi: abi, name: name, client:client, address: address)
© www.soinside.com 2019 - 2024. All rights reserved.