icekristal / laravel-chain-gateway-api
Laravel ChainGateway 服务 API
v3.0.0
2024-03-07 08:27 UTC
Requires
- php: ^8.2
- laravel/framework: ^8|^9|^10|^11
README
composer require icekristal/laravel-chain-gateway-api
API 文档
Tron: https://chaingateway.io/docs-tron
BNB: https://chaingateway.io/docs-binance-smart-chain
添加到 config/services.php !! 版本 1
'chain_gateway' => [ 'api' => env('CHAIN_GATEWAY_API', null), //API key chain gateway 'tron_url' => env('CHAIN_GATEWAY_TRON_URL', "https://eu.trx.chaingateway.io/v1"), 'token_trc20' => env('CHAIN_GATEWAY_TOKEN_TRC20', "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"), 'bsc_url' => env('CHAIN_GATEWAY_BSC_URL', "https://eu.bsc.chaingateway.io/v1"), 'token_bep20' => env('CHAIN_GATEWAY_TOKEN_BEP20', "0x55d398326f99059ff775485246999027b3197955"), 'logging' => [ 'channel_wallet' => env('CHAIN_GATEWAY_LOGGING_WALLET', null), 'channel_sended' => env('CHAIN_GATEWAY_LOGGING_SENDED', null), ], ],
添加到 config/services.php !! 版本 2
'chain_gateway' => [ 'version_api' => env('CHAIN_GATEWAY_API_VERSION', 'v2'), 'api' => env('CHAIN_GATEWAY_API', null), 'token_trc20' => env('CHAIN_GATEWAY_TOKEN_TRC20', null), 'token_bep20' => env('CHAIN_GATEWAY_TOKEN_BEP20', null), 'logging' => [ 'is_enable' => env('CHAIN_GATEWAY_LOGGING_IS_ENABLE', false), 'channel_wallet' => env('CHAIN_GATEWAY_LOGGING_WALLET', 'single'), 'channel_sended' => env('CHAIN_GATEWAY_LOGGING_SENDED', 'single'), 'channel_received' => env('CHAIN_GATEWAY_LOGGING_RECEIVED', 'single'), ], ],
方法
创建地址
$result = ChainGateway::createNewWalletTron(); // Tron address $result = ChainGateway::createNewWalletBNB(); // BNB address
订阅地址
$result = ChainGateway::subscribeTronAddress(string $addressFrom, string $url); // For trx transactions $result = ChainGateway::subscribeTRC20Address(string $addressFrom, string $hex); // For trc20 transactions - only version 1 $result = ChainGateway::subscribeBNBAddress(string $addressFrom, string $url); // For bnb transactions $result = ChainGateway::subscribeBEP20Address(string $addressFrom, string $hex); // For bnb transactions - only version 1
订阅列表
$result = ChainGateway::subscribeTronList(); // Tron $result = ChainGateway::subscribeBNBList(); // Bnb
取消订阅地址 !! 版本 1
$result = ChainGateway::unSubscribeTronAddress(string $addressFrom, string $url); // For trx transactions $result = ChainGateway::unSubscribeTRC20Address(string $addressFrom, string $url); // For trc20 transactions $result = ChainGateway::unSubscribeBNBAddress(string $addressFrom, string $url); // For bnb transactions $result = ChainGateway::unSubscribeBEP20Address(string $addressFrom, string $url); // For bnb transactions
取消订阅地址 !! 版本 2
$result = ChainGateway::unSubscribeTronAddress(string $webhookId); // For trx transactions $result = ChainGateway::unSubscribeBNBAddress(string $webhookId); // For bnb transactions
列出交易
$result = ChainGateway::getTronTransaction(string $tXId); // get info tron transaction $result = ChainGateway::getBNBTransaction(string $tXId); // get info bnb transaction
获取余额
$result = ChainGateway::getBNBBalance(string $address); // get BNB balance $result = ChainGateway::getBEP20Balance(string $address); // get bep20 balance $result = ChainGateway::getTronBalance(string $address); // get TRX balance $result = ChainGateway::getTRC20Balance(string $address); // get trc20 balance $type = 'trc20'; // variables: trx,bnb,bep20,trc20,trc_20,bep_20 $result = ChainGateway::balance($type, string $address); // get balance for type
发送加密货币
$result = ChainGateway::sendTron(string $addressFrom, string $privateKey, float $amount, string $addressTo); // send TRX $result = ChainGateway::sendTRC20(string $addressFrom, string $privateKey, float $amount, string $addressTo); // get trc20 balance $result = ChainGateway::sendBNB(string $addressFrom, string $privateKey, float $amount, string $addressTo); // get BNB balance $result = ChainGateway::sendBEP20(string $addressFrom, string $privateKey, float $amount, string $addressTo); // get bep20 balance $type = 'trc20'; // variables: trx,bnb,bep20,trc20,trc_20,bep_20 $result = ChainGateway::send($type, string $from, string $privateKey, float $amount, string $addressTo); // get balance for type