I was following this tutorial: https://moralis.io/nodejs-telegram-bot-tutorial-build-a-telegram-bot-using-nodejs/
I have finished setting up the Streams API up and running, i.e. I get the Transfer()
event when an ERC-20 token transfer happens, below are the specifications for my Streams API:
- Contract Address: 0x6f162ff7ef464858606e05855c762eeb751f56b3
- Webhook URL: https://5fb5-27-74-241-82.ap.ngrok.io/webhook
- Network: BSC Testnet
- I chose the
Topic0
to beTransfer(address,address,uint256)
Here is the payload I got from the Streams API UI:
{
"confirmed": true,
"chainId": "0x61",
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "previousAdminRole",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes32",
"name": "newAdminRole",
"type": "bytes32"
}
],
"name": "RoleAdminChanged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "RoleGranted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "account",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "RoleRevoked",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
],
"streamId": "719473ee-96d1-4a85-9be1-6245deb73eae",
"tag": "demo",
"retries": 0,
"block": {
"number": "30126385",
"hash": "0x78ff6516294eee39394d1a2e9634817343b5faeab005eb12be3d2bfe8ef5da6c",
"timestamp": "1685072485"
},
"logs": [
{
"logIndex": "27",
"transactionHash": "0xb7989e32038addacbf2a54585c1124e7444d1fb8134764de782da437f8fa07dd",
"address": "0x6f162ff7ef464858606e05855c762eeb751f56b3",
"data": "0x00000000000000000000000000000000000000000000000000000000000003ce",
"topic0": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"topic1": "0x000000000000000000000000f0355b92e55adfc147fff04517a17806e02dd969",
"topic2": "0x000000000000000000000000fcdda93b6251beefe41e003e6dd4070ac79f5e2c",
"topic3": null
}
],
"txs": [
{
"hash": "0xb7989e32038addacbf2a54585c1124e7444d1fb8134764de782da437f8fa07dd",
"gas": "149828",
"gasPrice": "10000000000",
"nonce": "90",
"input": "0x7ff36ab5000000000000000000000000000000000000000000000000000000000000028d0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000fcdda93b6251beefe41e003e6dd4070ac79f5e2c0000000000000000000000000000000000000000000000000000000064702f050000000000000000000000000000000000000000000000000000000000000002000000000000000000000000ae13d989dac2f0debff460ac112a837c89baa7cd0000000000000000000000006f162ff7ef464858606e05855c762eeb751f56b3",
"transactionIndex": "3",
"fromAddress": "0xfcdda93b6251beefe41e003e6dd4070ac79f5e2c",
"toAddress": "0xde2db97d54a3c3b008a097b2260633e6ca7db1af",
"value": "1000000000000000",
"type": "0",
"v": "230",
"r": "44706814527472766401393300369193026493864446188771623932550659802944090446380",
"s": "34284722724265255571958074559638893216924720874449973321969154869317097889584",
"receiptCumulativeGasUsed": "1493587",
"receiptGasUsed": "110874",
"receiptContractAddress": null,
"receiptRoot": null,
"receiptStatus": "1"
}
],
"txsInternal": [
{
"from": "0xde2db97d54a3c3b008a097b2260633e6ca7db1af",
"to": "0xae13d989dac2f0debff460ac112a837c89baa7cd",
"value": "1000000000000000",
"gas": "110182",
"transactionHash": "0xb7989e32038addacbf2a54585c1124e7444d1fb8134764de782da437f8fa07dd",
"internalTransactionIndex": "0"
}
],
"erc20Transfers": [
{
"transactionHash": "0xb7989e32038addacbf2a54585c1124e7444d1fb8134764de782da437f8fa07dd",
"logIndex": "27",
"contract": "0x6f162ff7ef464858606e05855c762eeb751f56b3",
"from": "0xf0355b92e55adfc147fff04517a17806e02dd969",
"to": "0xfcdda93b6251beefe41e003e6dd4070ac79f5e2c",
"value": "974",
"tokenName": "TEST",
"tokenSymbol": "TEST",
"tokenDecimals": "3",
"valueWithDecimals": "0.974",
"possibleSpam": true
}
],
"erc20Approvals": [],
"nftTokenApprovals": [],
"nftApprovals": {
"ERC721": [],
"ERC1155": []
},
"nftTransfers": [],
"nativeBalances": []
}
I was also able to set up the ngrok successfully, i.e. when I used Postman to call to the ngrok endpoint (exactly the same as what I provided in the Streams API Webhook URL), I can see the console.log
. Below is my code for the back-end:
require("dotenv").config();
const express = require("express");
const app = express();
const port = 3001;
app.use(express.json());
app.post("/webhook", async (req, res) => {
console.log("Webhook endpoint called");
const webhook = req.body;
console.log(webhook);
return res.status(200).json();
});
app.listen(port, () => {
console.log(`Listening for NFT Transfers on ${port}`);
});
With all of that, when a Transfer()
event is emitted and caught by the Streams API (what I got in the payload shown earlier), it doesnât call to my ngrok webhook endpoint and I donât see any error message.
Any help is greatly appreciated, if you need any more details, please let me know.