{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/go-ethereum/issues/16295","repository_url":"https://api.github.com/repos/ethereum/go-ethereum","labels_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/16295/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/16295/comments","events_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/16295/events","html_url":"https://github.com/ethereum/go-ethereum/issues/16295","id":304024836,"number":16295,"title":"API Calls Returning Incorrect Results","user":{"login":"the-jackalope","id":17994326,"avatar_url":"https://avatars1.githubusercontent.com/u/17994326?v=4","gravatar_id":"","url":"https://api.github.com/users/the-jackalope","html_url":"https://github.com/the-jackalope","followers_url":"https://api.github.com/users/the-jackalope/followers","following_url":"https://api.github.com/users/the-jackalope/following{/other_user}","gists_url":"https://api.github.com/users/the-jackalope/gists{/gist_id}","starred_url":"https://api.github.com/users/the-jackalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-jackalope/subscriptions","organizations_url":"https://api.github.com/users/the-jackalope/orgs","repos_url":"https://api.github.com/users/the-jackalope/repos","events_url":"https://api.github.com/users/the-jackalope/events{/privacy}","received_events_url":"https://api.github.com/users/the-jackalope/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-10T00:54:06Z","updated_at":"2018-03-10T17:11:39Z","closed_at":"2018-03-10T17:11:39Z","author_association":"NONE","body":"Hi there,\r\n\r\n#### Problem and steps to reproduce\r\n\r\nI'm having some trouble with the `ethclient.Client` not returning correct results from the network. When I try the same calls using `curl` I get the expected results.\r\n\r\n**Ex. 1: Querying balance from an address**\r\nIn go-ethereum:\r\n```go\r\napiKey := \"...\"\r\nconn, err := ethclient.Dial(\"https://mainnet.infura.io/\" + apiKey)\r\nout, err := conn.BalanceAt(context.Background(), common.StringToAddress(\"0xCdA03Cb85BA0e2bCBF6C7CaB1eA10203F6c30495\"), nil)\r\n\r\nfmt.Println(out.String()) // prints \"0\"\r\n```\r\nError handling is omitted for simplicity, but none of these methods error out. I'm not sure if it is worth mentioning that I am running this in a server goroutine, but since I haven't seen that listed as an issue anywhere I'm assuming it is not.\r\n\r\nThe result is incorrect as I can see from etherscan.io that the account has ether. Furthermore, when performing the query using JSON RPC:\r\n```bash\r\n$ curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBalance\",\"params\":[\"0xCdA03Cb85BA0e2bCBF6C7CaB1eA10203F6c30495\", \"latest\"],\"id\":1}' https://mainnet.infura.io/$API_KEY\r\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":\"0x28d3cfae09e00\"}\r\n```\r\nI receive the correct result.\r\n\r\n**Ex. 1: Making a contract call**\r\nI'm using the [EOS contract](https://etherscan.io/token/EOS#readContract) as an example:\r\n```go\r\neosAddr := common.StringToAddress(\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\")\r\nconn, err := ethclient.Dial(\"https://mainnet.infura.io/\" + apiKey)\r\nparsedBytes, err := abi.JSON(strings.NewReader(tokenABI))\r\ncontract := bind.NewBoundContract(eosAddr, parsedBytes, conn, nil, nil)\r\n\r\nret := new([32]byte)\r\nerr := contract.Call(nil, ret, \"symbol\")\r\n// err message: \"no contract code at given address\"\r\n```\r\n\r\nWhereas with the JSON RPC:\r\n```bash\r\n$ curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\", \"method\":\"eth_call\", \"params\":[{\"to\": \"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\", \"data\": \"0x95d89b410000000000000000000000000000000000000000000000000000000000000000\"}, \"latest\"], \"id\":1}' https://mainnet.infura.io/$API_KEY\r\n\r\n{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":\"0x454f530000000000000000000000000000000000000000000000000000000000\"}\r\n```\r\n\r\nAgain, the RPC returns the correct answer. When I use the geth API I seem to either receive no error, or incorrect error messages (seeing as a contract definitely exists at the address). Any results returned seem to be incorrect compared to the RPC. I'd love to know if I'm using the API incorrectly, or to help get to the bottom of this. Many thanks!\r\n\r\n\r\n#### System information\r\n\r\nGeth version: `1.8.2-stable`\r\nOS & Version: macOS High Sierra 10.13.13 "},"comment":{"url":"https://api.github.com/repos/ethereum/go-ethereum/issues/comments/372045720","html_url":"https://github.com/ethereum/go-ethereum/issues/16295#issuecomment-372045720","issue_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/16295","id":372045720,"user":{"login":"the-jackalope","id":17994326,"avatar_url":"https://avatars1.githubusercontent.com/u/17994326?v=4","gravatar_id":"","url":"https://api.github.com/users/the-jackalope","html_url":"https://github.com/the-jackalope","followers_url":"https://api.github.com/users/the-jackalope/followers","following_url":"https://api.github.com/users/the-jackalope/following{/other_user}","gists_url":"https://api.github.com/users/the-jackalope/gists{/gist_id}","starred_url":"https://api.github.com/users/the-jackalope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/the-jackalope/subscriptions","organizations_url":"https://api.github.com/users/the-jackalope/orgs","repos_url":"https://api.github.com/users/the-jackalope/repos","events_url":"https://api.github.com/users/the-jackalope/events{/privacy}","received_events_url":"https://api.github.com/users/the-jackalope/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T17:11:39Z","updated_at":"2018-03-10T17:11:39Z","author_association":"NONE","body":"Oh my goodness that worked like magic! Thanks for the help, really appreciate it. I was scratching my head over here. I'll close this issue."}}
{"actor":{"display_login":"the-jackalope"}}