TRON区块链API服务 · 生成钱包 · 查询余额 · 转账 · 助记词
返回64位hex私钥和T开头钱包地址
curl https://tronapi.net/api/address/generate
{
"success": true,
"data": {
"privatekey": "abc...",
"wallet": "Txxx..."
}
}
生成BIP39标准12个英文助记词
curl https://tronapi.net/api/mnemonic/generate
返回:
{"success":true,"data":{"result":"成功","mnemonic":"word1 word2 ... word12"}}
输入12个BIP39助记词,返回私钥和钱包地址
curl -X POST https://tronapi.net/api/mnemonic/recover \
-H "Content-Type: application/json" \
-d '{"mnemonic":"abandon ability able about above absent absorb abstract access accident account acquire"}'
返回:
{"success":true,"data":{"result":"成功","privatekey":"abc...","wallet":"Txxx..."}}
输入12个BIP39助记词,返回64位hex私钥
curl -X POST https://tronapi.net/api/mnemonic/to-private-key \
-H "Content-Type: application/json" \
-d '{"mnemonic":"word1 word2 ... word12"}'
返回:
{"success":true,"data":{"result":"成功","private_key":"64位hex私钥"}}
curl -X POST https://tronapi.net/api/address/from-private-key \
-H "Content-Type: application/json" \
-d '{"private_key":"64位hex私钥"}'
curl -X POST https://tronapi.net/api/balance/trx \
-H "Content-Type: application/json" \
-d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC"}'
返回:
{"success":true,"data":{"result":"成功","address":"Txxx...","balance":"163.331747","unit":"TRX"}}
curl -X POST https://tronapi.net/api/balance/trc20 \
-H "Content-Type: application/json" \
-d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC"}'
返回:
{"success":true,"data":{"result":"成功","address":"Txxx...","token":"USDT","balance":"8550.739694"}}
curl -X POST https://tronapi.net/api/transfer/trx \
-H "Content-Type: application/json" \
-d '{
"private_key":"你的64位私钥",
"to":"收款T地址",
"amount":100
}'
| 参数 | 说明 |
|---|---|
| private_key | 64位hex私钥 |
| to | 收款地址(T开头或41开头) |
| amount | 转账数量(TRX) |
返回:
// 成功
{"success":true,"data":{"result":"成功","txID":"交易哈希..."}}
// 失败
{"success":false,"data":{"result":"失败","reason":"余额不足"}}
curl -X POST https://tronapi.net/api/transfer/trc20 \
-H "Content-Type: application/json" \
-d '{
"private_key":"你的64位私钥",
"to":"收款T地址",
"amount":100
}'
| 参数 | 说明 |
|---|---|
| private_key | 64位hex私钥 |
| to | 收款地址(T开头或41开头) |
| amount | 转账数量(USDT) |
返回:
// 成功
{"success":true,"data":{"result":"成功","txID":"交易哈希..."}}
// 失败
{"success":false,"data":{"result":"失败","reason":"余额不足"}}
curl -X POST https://tronapi.net/api/transaction/trc20 \
-H "Content-Type: application/json" \
-d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC","limit":50}'
curl -X POST https://tronapi.net/api/transaction/by-address \
-H "Content-Type: application/json" \
-d '{"address":"TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC","limit":50}'
<?php
// 生成钱包
$res = file_get_contents('https://tronapi.net/api/address/generate');
print_r(json_decode($res, true));
// 查余额
$ch = curl_init('https://tronapi.net/api/balance/trx');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'address' => 'TPhh7UeRf4h6SaU69RqQdRepT3sDHKVTUC'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
print_r(json_decode(curl_exec($ch), true));