Open wtmit opened 7 months ago
$erc20TokenBalance = $contract->at($erc20TokenAddress)->call('balanceOf', [$accountAddress], function($err, $result) { if ($err !== null) { echo 'Error: ' . $err->getMessage() . PHP_EOL; // return; }
print_r($result);
});
Try this: $contract = new Contract(rpcurl, abi);
$contract->at(tokenAddress)->call('balanceOf', address, [
'from' => address,
], function ($err, $result) use ($contract) {
if ($err !== null) {
$this->res['err'] = $err->getMessage();
}
if (isset($result)) {;
$bn = Utils::toBn($result[0]);
$this->res['amount'] = bcdiv($bn->toString(), 10 ** 18, 18);
}
});
<?php
require('../vendor/autoload.php');
use Web3\Providers\HttpProvider; use Web3\Web3; use Web3\Contract;
$accountAddress = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $erc20TokenAddress = '0x11B9EC22a5fe98a5b2566E508cc66fCB44Ab1506'; $erc20TokenDecimal = 18;
// Create contract instance $contract = new Contract($web3->provider, $erc20TokenABI);
The symbol: WTM PHP Warning: Array to string conversion in D:\xampp\htdocs\web3.php-master\src\Contracts\Types\Address.php on line 63
Warning: Array to string conversion in D:\xampp\htdocs\web3.php-master\src\Contracts\Types\Address.php on line 63 PHP Fatal error: Uncaught InvalidArgumentException: Please make sure you have put all function params and callback. in D:\xampp\htdocs\web3.