PHP code example of kornrunner / ethereum-token
1. Go to this page and download the library: Download kornrunner/ethereum-token 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/ */
kornrunner / ethereum-token example snippets
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;
$nonce = '04';
$gasPrice = '03f5476a00';
$gasLimit = '027f4b';
$to = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$privateKey = 'b2f2698dd7343fa5afc96626dee139cb92e58e5d04e855f4c712727bf198e898';
$token = new Token;
$usdt = new Token\USDT;
$amount = 20;
$hexAmount = $token->hexAmount($usdt, $amount);
// 0x1312d00
$data = $token->getTransferData($to, $hexAmount);
// 0xa9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00
$transaction = new Transaction($nonce, $gasPrice, $gasLimit, $usdt::ADDRESS, '', $data);
$transaction->getRaw($privateKey);
// f8a9048503f5476a0083027f4b94dac17f958d2ee523a2206206994597c13d831ec7b844a9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00801ba03e141ea4233ec00bb3a80d7fea5f774b736772851b7bad18453d0f3c6097c42e9fa6eb47b6bead6a76d7db12809e2c916df999d7b99b613fcaa135abd8a0078e