Skip to content

add tron network(TRX) address support #38

@bolpol

Description

@bolpol

Tron is not token yet.

This code return valid tron address. Please update your code to was possible get address from a box.

./hd-wallet-derive/hd-wallet-derive.php --coin=ETH --mnemonic="mnemonic" --mnemonic-pw="password" --path="m/44'/195'/0'/0/0"  -g  --numderive=1 --format=csv
use BitcoinPHP\BitcoinECDSA\BitcoinECDSA;
use IEXBase\TronAPI\Support\Utils as TronUtils;
use IEXBase\TronAPI\Tron;

$fullNode = new HttpProvider('https://api.trongrid.io');
$solidityNode = new HttpProvider('https://api.trongrid.io');
$eventServer = new HttpProvider('https://api.trongrid.io');
$blockchain =  new Tron($fullNode, $solidityNode, $eventServer);

function getTronAddress($privateKey)
{
    $bitcoinECDSA = new BitcoinECDSA();
    $bitcoinECDSA->setPrivateKey($privateKey);
    $publicKey = $bitcoinECDSA->getUncompressedPubKey();
    $address = TronUtils::pubKeyToAddress($publicKey);
    return $blockchain ->hexString2Address($address);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions