Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bep20 failed to obtain balance #24

Open
leo98123 opened this issue Feb 18, 2025 · 0 comments
Open

bep20 failed to obtain balance #24

leo98123 opened this issue Feb 18, 2025 · 0 comments

Comments

@leo98123
Copy link

my code:
$apiKey = 'my apikey************';
$api = new \Binance\BscscanApi($apiKey);
$config = [
'contract_address' => '0x55d398326f99059fF775485246999027B3197955',// USDT BEP20
'decimals' => 18,
];
$address = '0xA3E043CA89B6dA1ae800a4816ff22afea1e2cAcf';
$bep20 = new \Binance\BEP20($api, $config);
$usdtBalance = $bep20->balance($address);
echo $usdtBalance;

My code is as above. No matter which address is filled in, the return is 0.000000014. I entered the code debugging and found that BEP20.PHP
method:
public function balance(string $address)
{
$params = [];
$params['to'] = $this->contractAddress;
$method = 'balanceOf(address)';
$formatMethod = Formatter::toMethodFormat($method);
$formatAddress = Formatter::toAddressFormat($address);

$params['data'] = "0x{$formatMethod}{$formatAddress}";
$balance = $this->proxyApi->ethCall($params);
echo "ethCall Response: " . json_encode($balance) . "
";
return Utils::toDisplayAmount($balance, $this->decimals);
}
The debugging result is:
ethCall Response: "Error!"

I don't know what went wrong now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant