{"action":"opened","issue":{"url":"https://api.github.com/repos/EthWorks/ethereum.rb/issues/111","repository_url":"https://api.github.com/repos/EthWorks/ethereum.rb","labels_url":"https://api.github.com/repos/EthWorks/ethereum.rb/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/EthWorks/ethereum.rb/issues/111/comments","events_url":"https://api.github.com/repos/EthWorks/ethereum.rb/issues/111/events","html_url":"https://github.com/EthWorks/ethereum.rb/issues/111","id":384171442,"node_id":"MDU6SXNzdWUzODQxNzE0NDI=","number":111,"title":"Incorrect nonce when changing private key","user":{"login":"longhoangwkm","id":34698136,"node_id":"MDQ6VXNlcjM0Njk4MTM2","avatar_url":"https://avatars1.githubusercontent.com/u/34698136?v=4","gravatar_id":"","url":"https://api.github.com/users/longhoangwkm","html_url":"https://github.com/longhoangwkm","followers_url":"https://api.github.com/users/longhoangwkm/followers","following_url":"https://api.github.com/users/longhoangwkm/following{/other_user}","gists_url":"https://api.github.com/users/longhoangwkm/gists{/gist_id}","starred_url":"https://api.github.com/users/longhoangwkm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/longhoangwkm/subscriptions","organizations_url":"https://api.github.com/users/longhoangwkm/orgs","repos_url":"https://api.github.com/users/longhoangwkm/repos","events_url":"https://api.github.com/users/longhoangwkm/events{/privacy}","received_events_url":"https://api.github.com/users/longhoangwkm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-26T04:37:17Z","updated_at":"2018-11-26T04:37:17Z","closed_at":null,"author_association":"NONE","body":"```ruby\r\nclass EthereumClient\r\n  ENCODER = Ethereum::Encoder.new\r\n  ETHEREUM_NETWORK_URL = ENV.fetch('ETHEREUM_NETWORK_URL')\r\n\r\n  def self.client\r\n    return @client if @client\r\n\r\n    @client = Ethereum::HttpClient.new(ETHEREUM_NETWORK_URL)\r\n    @client.default_account = '0xaaaa'\r\n    @client\r\n  end\r\n```\r\n\r\n```ruby\r\nclass SmartContract\r\n  attr_accessor :contract_instance\r\n\r\n  ENCODER = Ethereum::Encoder.new\r\n\r\n  def initialize(name, address, code, abi)\r\n    @contract_instance = Ethereum::Contract.create(\r\n      name: name,\r\n      address: address,\r\n      code: code,\r\n      abi: abi,\r\n      client: EthereumClient.client\r\n    )\r\n  end\r\n\r\n  def transfer(from_private_hex, to_address, amount)\r\n    key = Eth::Key.new priv: from_private_hex\r\n    @contract_instance.key = key\r\n    @contract_instance.transact.transfer__address__uint256(to_address, amount)\r\n  end\r\n```\r\n\r\n```ruby\r\ncontract = SmartContract.new(NAME, ADDRESS, CODE, ABI)\r\ncontract.transfer(from_private_hex, to_address, amount)\r\n```\r\nI have multi account A,B, C\r\nWhen i wanna transfer account token from A,B,C to D.\r\nA worked as well.\r\nBut when i create tx for B. B's tx nonce get nonce number from A. I should be change nonce when i assign a new private_key"}}
{"actor":{"display_login":"longhoangwkm"}}