PHP code example of furqansiddiqui / erc20-php

1. Go to this page and download the library: Download furqansiddiqui/erc20-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

furqansiddiqui / erc20-php example snippets


use FurqanSiddiqui\Ethereum\RPC\Infura;
use FurqanSiddiqui\Ethereum\ERC20\ERC20;

$infura = new Infura("PROJECT-ID", "PROJECT-SECRET");
$infura->ignoreSSL(); // In case Infura.IO SSL errors (or provide "caRootFile:" to constructor above)

$erc20 = new ERC20($infura);
$usdt = $erc20->deployedAt("0xdac17f958d2ee523a2206206994597c13d831ec7");
var_dump($usdt->name());
var_dump($usdt->symbol());
var_dump($usdt->decimals());
var_dump($usdt->totalSupply());
$balance = $usdt->balanceOf($eth->getAccount("ETHEREUM-ADDRESS"));
var_dump($balance);
var_dump($usdt->getScaledValue($balance));

use \FurqanSiddiqui\Ethereum\Contracts\Contract;

$customABI  =   Contract::fromArray(json_decode(file_get_contents("YOUR-CUSTOM-ABI.json"), true), true);
$erc20 = new ERC20(abi: $customABI);