PHP code example of mitoop / crypto-php

1. Go to this page and download the library: Download mitoop/crypto-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/ */

    

mitoop / crypto-php example snippets


use Mitoop\Crypto\Factory;

// Get native coin instance
$token = Factory::createCoin([
   'chain' => 'eth', // Blockchain: eth (Ethereum)/bsc (Binance Smart Chain)/polygon (Polygon)/tron (TRON)
   'chain_id' => 11155111, // Blockchain ID (Tron can be set to 0)
   'rpc_url' => 'https://sepolia.infura.io/v3/your_api_key', // RPC URL
   'rpc_api_key' => '', // API key (leave empty if none)
   'explorer_url' => 'https://sepolia.etherscan.io' // Explorer URL
]);
$token->generateWallet();
$token->getBalance();
//...

// Get token instance
$token = Factory::createToken([
   'chain' => 'eth', // Blockchain: eth (Ethereum)/bsc (Binance Smart Chain)/polygon (Polygon)/tron (TRON)
   'chain_id' => 11155111, // Blockchain ID (Tron can be set to 0)
   'contract_address' => '0x779877A7B0D9E8603169DdbD7836e478b4624789', // Token contract address
   'decimals' => 18, // Token decimals
   'rpc_url' => 'https://sepolia.infura.io/v3/your_api_key', // RPC URL
   'rpc_api_key' => '', // API key (leave empty if none)
   'explorer_url' => 'https://sepolia.etherscan.io' // Explorer URL
]);
$token->generateWallet();
$token->getBalance();
//...

// You can get the native coin instance from a token
$coin = $token->getNativeCoin();
$coin->getBalance();
//...
text
composer