Skip to content

Instantly share code, notes, and snippets.

@AminAlizadeh-m
Last active January 20, 2023 15:57
Show Gist options
  • Save AminAlizadeh-m/781b5ff269e07f731411d7fa513bf4a0 to your computer and use it in GitHub Desktop.
Save AminAlizadeh-m/781b5ff269e07f731411d7fa513bf4a0 to your computer and use it in GitHub Desktop.
Get tron transaction with TatumAPI
// Get latest transaction of tron (TRC20 Tokens Like USDT)
const tatumURL = 'https://api.tatum.io/v3'; // https://tatum.io : Get more info and read docs and get a free api key!
const axiosRequestConfig: AxiosRequestConfig = {
headers: { 'x-api-key': 'TATUM_API_KEY' },
};
const address = 'TRON_ACCOUNT_ADDRESS'; // you can get from trust wallet or generate by your self
const { data } = await axios.get(
`${tatumURL}/tron/transaction/account/${address}/trc20`,
axiosRequestConfig,
);
// This API returns up to 200 transactions in one API call. If there are more than 200 transactions for the TRON account, the response body will contain the next parameter with the fingerprint of the transaction that follows the last (200th) transaction in the returned list.(READ DOCS PLEASE) => https://apidoc.tatum.io/tag/Tron#operation/TronAccountTx20
// Response:
/*
{
"next": "81d0524acf5967f3b361e03fd7d141ab511791cd7aad7ae406c4c8d408290991",
"transactions": [
{
"txID": "24dd2f121a24516f22df78adf1ccc32119e3edb7760297f76a925b879f2baa98", // ای دی تراکنش جهت مشاهده در اسکنر ها https://tronscan.org/
"tokenInfo": {
"symbol": "USDT",
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // USDT contract address in tron همیشه باید همین مقدار باشد برای تتر در شبکه ترون
"decimals": 6, // تعداد رقم های بعد از اعشار
"name": "Tether USD"
},
"from": "TPn72oEg7WPaffgNBf62vGx8G1s4chx2fp", // This will be your customer address آدرس ولت ترون مشتری
"to": "TJyhbP1bQfo8tLPxEVjaka9gh2qkN7MvD3", // This wall be your address آدرس ولت ترون فروشنده (خودت)
"type": "Transfer",
"value": "1800" // Value مقدار واریزی
}
]
}
این رو در یک کرون جاب مثلا هر ۵ دقیقه یکبار اجرا کن اگر ترنزاکشن جدید بیاد توی ریسپانس اضافه میشه
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment