【问题标题】:Cannot unmarshal non-string into Go struct field SendTxArgs.from of type common.Address无法将非字符串解组到常见类型的 Go 结构字段 SendTxArgs.from 中。地址
【发布时间】:2017-12-14 09:42:54
【问题描述】:

我正在使用 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】:

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

    就我而言,我是这样添加的:

    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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-04
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 2020-10-14
      相关资源
      最近更新 更多