furqansiddiqui / erc20-php

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

can't get token value #18

Closed alexwale closed 4 years ago

alexwale commented 4 years ago

hi there, i use those functions ,but get all value was null, i don't why can you help me to fix it ? thanks a lot . here is my result. code: $geth = new EthereumRPC('127.0.0.1', 8545); $erc20 = new \ERC20\ERC20($geth); $token = $erc20->token('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07');

    var_dump($token->name());
    var_dump($token->symbol());
    var_dump($token->decimals());

result: string(0) "" string(0) "" int(0)

r00ts3ctors commented 4 years ago

some i not get it, any body can give some solution ?

I used geth erespond@notebook://home/erespond/Desktop/coba3$ geth --syncmode "light" --rpc --rpcaddr 192.168.100.5 --rpcapi="db,eth,net,web3,personal,web3" INFO [10-23|03:28:23.684] Dropping default light client cache provided=1024 updated=128 INFO [10-23|03:28:23.685] Maximum peer count ETH=0 LES=10 total=50 INFO [10-23|03:28:23.685] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory" INFO [10-23|03:28:23.687] Starting peer-to-peer node instance=Geth/v1.9.6-stable-bd059680/linux-amd64/go1.11.5 INFO [10-23|03:28:23.687] Allocated cache and file handles database=/home/erespond/.ethereum/geth/lightchaindata cache=64.00MiB handles=2048 INFO [10-23|03:28:23.811] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersburg: 7280000 Istanbul: Engine: ethash}" INFO [10-23|03:28:23.811] Disk storage enabled for ethash caches dir=/home/erespond/.ethereum/geth/ethash count=3 INFO [10-23|03:28:23.811] Disk storage enabled for ethash DAGs dir=/home/erespond/.ethash count=2 INFO [10-23|03:28:23.820] Added trusted checkpoint block=8552447 hash=613fc3…9428eb INFO [10-23|03:28:23.820] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184 age=50y6mo1w INFO [10-23|03:28:23.821] Configured checkpoint registrar address=0x9a9070028361F7AAbeB3f2F2Dc07F82C4a98A02a signers=5 threshold=2 INFO [10-23|03:28:23.842] UDP listener up net=enode://7b60a4d4bc471e31ba38a52ea01a053c7791a399f40fbaaf759890ee92772e1994ab8d65f2eb8a84137f906d4959f93a7347be8898193d6404159f5d525c2117@[::]:30303 WARN [10-23|03:28:23.845] Light client mode is an experimental feature INFO [10-23|03:28:23.847] New local node record seq=2 id=1938ba47425ce4be ip=127.0.0.1 udp=30303 tcp=30303 INFO [10-23|03:28:23.847] Started P2P networking self=enode://7b60a4d4bc471e31ba38a52ea01a053c7791a399f40fbaaf759890ee92772e1994ab8d65f2eb8a84137f906d4959f93a7347be8898193d6404159f5d525c2117@127.0.0.1:30303 INFO [10-23|03:28:23.847] IPC endpoint opened url=/home/erespond/.ethereum/geth.ipc INFO [10-23|03:28:23.848] HTTP endpoint opened url=http://192.168.100.5:8545 cors= vhosts=localhost

and code for php <?php require('vendor/autoload.php');

use EthereumRPC\EthereumRPC; use ERC20\ERC20;

$geth = new EthereumRPC('192.168.100.5', 8545); // $geth = new EthereumRPC('192.168.100.5', 8545); $erc20 = new \ERC20\ERC20($geth);

$token = $erc20->token('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07');

var_dump($token->name()); var_dump($token->symbol()); var_dump($token->decimals()); ?>

result: string(0) "" string(0) "" int(0)

furqansiddiqui commented 4 years ago

I am not certain but this may have something to do with your node being synced in light mode. This lib is in use in production envs where Geth node is synced in full mode.