furqansiddiqui / erc20-php

Interact with Ethereum ERC20 Tokens
MIT License
163 stars 96 forks source link

Unable to retrieve data? #7

Closed iScripters closed 6 years ago

iScripters commented 6 years ago

I've set up a Ropsten node and let it sync fully, then tried to get some information about a contract but it doesn't seem to be able to. Am I missing something?

<?php
require 'vendor/autoload.php';
use EthereumRPC\EthereumRPC;
use ERC20\ERC20;

$geth = new EthereumRPC('1xx.6x.3x.2xx', 8545);
$erc20 = new \ERC20\ERC20($geth);
$erc20->abiPath('assets/abi.json'); // ABI copy/pasted from Etherscan's contract page
$token = $erc20->token('0x24095DF431df6E9eD4E48b75E39080793Ca888b0');

var_dump($token);

Returns:

object(ERC20\ERC20_Token)#70 (6) {
  ["_name":"ERC20\ERC20_Token":private]=>
  NULL
  ["_symbol":"ERC20\ERC20_Token":private]=>
  NULL
  ["_decimals":"ERC20\ERC20_Token":private]=>
  NULL
(...)

(Left the rest out to not create a wall of text)

Entries from the composer.json:

        "furqansiddiqui/http-client": "dev-master",
        "furqansiddiqui/ethereum-rpc": "^0.1.2",
        "furqansiddiqui/erc20-php": "^0.1.2"

Edit: Tried using web3.py, which throws an error as well. Changed the node url in the Python version which then did return the desired result. Conclusion: My node is causing the issue.

jimbrouwer commented 5 years ago

I'm facing the exact same problem.

I noticed my node had some issues with syncing. After removedb and restarting geth the problems occurred.

What did you do in order to fix your node?