{ "name": "Monitor USDT Balance on Telegram", "tags": [], "nodes": [ { "id": "monitor-usdt-balance-on-telegram-0", "name": "Balance Changed?", "type": "n8n-nodes-base.if", "position": [ -40, 0 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{$json.balanceChanged}}", "value2": true } ] } }, "typeVersion": 1 }, { "id": "monitor-usdt-balance-on-telegram-1", "name": "Balance Changed.", "type": "n8n-nodes-base.telegram", "position": [ 320, -140 ], "parameters": { "text": "={{ $json.text }}", "chatId": "YOUR_TELEGRAM_CHAT_ID", "additionalFields": { "parse_mode": "Markdown", "appendAttribution": false } }, "typeVersion": 1 }, { "id": "monitor-usdt-balance-on-telegram-2", "name": "Balance Not Changed.", "type": "n8n-nodes-base.telegram", "position": [ 320, 20 ], "parameters": { "text": "={{ $json.text }}", "chatId": "YOUR_TELEGRAM_CHAT_ID", "additionalFields": { "parse_mode": "Markdown", "appendAttribution": false } }, "typeVersion": 1 }, { "id": "monitor-usdt-balance-on-telegram-3", "name": "userData", "type": "n8n-nodes-base.set", "position": [ -780, 0 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "4455d1e7-a489-4ab6-a526-4fc755db99d0", "name": "Your Wallet Address", "type": "string", "value": "YOUR_ETHEREUM_WALLET_ADDRESS" }, { "id": "971ea723-e3de-4cff-b4e7-5899f3d8fb00", "name": "USDT ERC-20 Token Address", "type": "string", "value": "0xdAC17F958D2ee523a2206206994597C13D831ec7" } ] } }, "typeVersion": 3.4 }, { "id": "monitor-usdt-balance-on-telegram-4", "name": "balanceChecker", "type": "n8n-nodes-base.code", "position": [ -280, 0 ], "parameters": { "jsCode": "function calculateUsdt({balance,wallet,contract,previous}){\n if(typeof balance!=='string'||!/^\\d+$/.test(balance))throw Error('Invalid token balance');\n if(previous!=null&&(typeof previous!=='object'||typeof previous.key!=='string'||typeof previous.balance!=='string'||!/^\\d+$/.test(previous.balance)))throw Error('Invalid saved balance');\n const key=wallet.toLowerCase()+':'+contract.toLowerCase(),last=previous?.key===key&&typeof previous.balance==='string'&&/^\\d+$/.test(previous.balance)?previous.balance:balance;\n const amount=x=>{const s=x.replace(/^0+(?=\\d)/,'').padStart(7,'0'),whole=s.slice(0,-6),fraction=s.slice(-6).replace(/0+$/,'');return fraction?whole+'.'+fraction:whole};\n const changed=last!==balance,text=changed?`🚨 *USDT Balance Change!*\\n\\nWallet Address: ${wallet}\\n\\n🔴 Previous Balance: ${amount(last)} USDT\\n\\n🟢 New Balance: ${amount(balance)} USDT`:'Balance Unchanged. USDT balance remained stable.';\n return {next:{key,balance},changed,text};\n}\n\nconst input=$('userData').first().json, wallet=input['Your Wallet Address'],contract=input['USDT ERC-20 Token Address'];if(!/^0x[0-9a-fA-F]{40}$/.test(wallet)||!/^0x[0-9a-fA-F]{40}$/.test(contract)||$json.status!=='1')throw Error('Invalid balance response or address');const store=$getWorkflowStaticData('global'),r=calculateUsdt({balance:$json.result,wallet,contract,previous:store.usdtBalance});store.usdtBalance=r.next;return [{json:{balanceChanged:r.changed,previousBalance:r.next.balance,currentBalance:$json.result,walletAddress:wallet,text:r.text}}];" }, "typeVersion": 2 }, { "id": "monitor-usdt-balance-on-telegram-5", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ -1040, -180 ], "parameters": { "color": 4, "width": 1540, "height": 400, "content": "## USDT ERC-20 Wallet Balance Tracker\n**This workflow** Is a basic concept of integrating your ERC-20 wallet with n8n nodes." }, "typeVersion": 1 }, { "id": "monitor-usdt-balance-on-telegram-6", "name": "Check Balance Every 5 Minutes", "type": "n8n-nodes-base.cron", "position": [ -1000, 0 ], "parameters": { "triggerTimes": { "item": [ { "mode": "everyX", "unit": "minutes", "value": 5 } ] } }, "typeVersion": 1 }, { "id": "monitor-usdt-balance-on-telegram-7", "name": "Fetch USDT Balance from Etherscan", "type": "n8n-nodes-base.httpRequest", "position": [ -480, 0 ], "parameters": { "method": "GET", "url": "https://api.etherscan.io/v2/api", "authentication": "genericCredentialType", "genericAuthType": "httpQueryAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "chainid", "value": "1" }, { "name": "module", "value": "account" }, { "name": "action", "value": "tokenbalance" }, { "name": "address", "value": "={{ $json[\"Your Wallet Address\"] }}" }, { "name": "contractaddress", "value": "={{ $json[\"USDT ERC-20 Token Address\"] }}" }, { "name": "tag", "value": "latest" } ] }, "options": { "response": { "response": { "responseFormat": "json" } } } }, "typeVersion": 4.2 } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1" }, "connections": { "userData": { "main": [ [ { "node": "Fetch USDT Balance from Etherscan", "type": "main", "index": 0 } ] ] }, "balanceChecker": { "main": [ [ { "node": "Balance Changed?", "type": "main", "index": 0 } ] ] }, "Balance Changed.": { "main": [ [] ] }, "Balance Changed?": { "main": [ [ { "node": "Balance Changed.", "type": "main", "index": 0 } ], [ { "node": "Balance Not Changed.", "type": "main", "index": 0 } ] ] }, "Check Balance Every 5 Minutes": { "main": [ [ { "node": "userData", "type": "main", "index": 0 } ] ] }, "Fetch USDT Balance from Etherscan": { "main": [ [ { "node": "balanceChecker", "type": "main", "index": 0 } ] ] } } }