{"action":"closed","issue":{"url":"https://api.github.com/repos/izetex/web3-eth/issues/6","repository_url":"https://api.github.com/repos/izetex/web3-eth","labels_url":"https://api.github.com/repos/izetex/web3-eth/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/izetex/web3-eth/issues/6/comments","events_url":"https://api.github.com/repos/izetex/web3-eth/issues/6/events","html_url":"https://github.com/izetex/web3-eth/issues/6","id":295448228,"number":6,"title":"Getting Contract Instance","user":{"login":"woniesong92","id":2935309,"avatar_url":"https://avatars1.githubusercontent.com/u/2935309?v=4","gravatar_id":"","url":"https://api.github.com/users/woniesong92","html_url":"https://github.com/woniesong92","followers_url":"https://api.github.com/users/woniesong92/followers","following_url":"https://api.github.com/users/woniesong92/following{/other_user}","gists_url":"https://api.github.com/users/woniesong92/gists{/gist_id}","starred_url":"https://api.github.com/users/woniesong92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woniesong92/subscriptions","organizations_url":"https://api.github.com/users/woniesong92/orgs","repos_url":"https://api.github.com/users/woniesong92/repos","events_url":"https://api.github.com/users/woniesong92/events{/privacy}","received_events_url":"https://api.github.com/users/woniesong92/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-08T09:55:19Z","updated_at":"2018-02-15T04:08:40Z","closed_at":"2018-02-15T04:08:40Z","author_association":"NONE","body":"I am having some trouble trying to get a contract instance and call its methods from Rails. I am using truffle, web3-eth, and Rails 5.0+.\r\n\r\nI deployed my contract to ropsten and got the abi. The abi looks like this:\r\n\r\n```\r\nabi = [\r\n  {\r\n    \"constant\": false,\r\n    \"inputs\": [\r\n      {\r\n        \"name\": \"_to\",\r\n        \"type\": \"address\"\r\n      },\r\n      {\r\n        \"name\": \"_tokenId\",\r\n        \"type\": \"uint256\"\r\n      }\r\n    ],\r\n    \"name\": \"approve\",\r\n    \"outputs\": [],\r\n    \"payable\": false,\r\n    \"stateMutability\": \"nonpayable\",\r\n    \"type\": \"function\"\r\n  },\r\n  ...\r\n]\r\n```\r\n\r\nI first tried using this like this:\r\n\r\n```\r\n    web3 = Web3::Eth::Rpc.new host: 'localhost',\r\n                              port: 9545,\r\n                              connect_options: {\r\n                                use_ssl: false,\r\n                                read_timeout: 120\r\n                              }\r\n\r\n    abi = [...]\r\n    @contract = web3.eth.contract(abi);\r\n    @contract_instance = @contract.at(CONTRACT_ADDRESS)\r\n```\r\n\r\nBut I kept getting the exception `RuntimeError: No method found in ABI`.\r\nSo I looked at how a contract instance is initialized, I noticed you're expecting `abi` to be a single element rather than an array of objects.\r\n\r\nIs there anything I'm misunderstanding?"}}
{"actor":{"display_login":"woniesong92"}}