What would be involved in watching a few specific contract addresses for Transfer event on Ethereum or Polygon?

Moralis Streams API is what I'm using now but it can get pricey with the number of daily computes and records.

1 Answer 1


Hi Developer advocate from Chainstack here.

At the lowest code implementation level, you can use Ethereum's subscription API, in your particular case, you can subscribe to the logs.

Below is a sample code you can try out. This code subscribes to USDT's transfer event. It is modified from this tutorial.

const Web3 = require("web3");
//visit Chainstack doc for more information:

// ws url
const ws_url = "wss://ws-nd-610-406-547.fill-in-your-ws-endpoint-here.com/fill-in-your-ws-endpoint-here"
const web3 = new Web3(ws_url)

// subscribe to logs
// for SushiSwap: MasterChef LP Staking Pool withdraw events on mainnet
var logs = web3.eth
        "logs", {
            //SushiSwap: MasterChef LP Staking Pool
            address: "0xdac17f958d2ee523a2206206994597c13d831ec7",
            topics: [
                //Transfer (index_topic_1 address from, index_topic_2 address to, uint256 value)
        function(error, result) {
            if (!error) console.log(result);
    .on("connected", function(subscriptionId) {
        console.log("sub id:" + subscriptionId);
    .on("data", function(log) {
    .on("changed", function(log) {});

//keep this code alive
setInterval(() => {}, 1 << 30);

The WebSocket endpoint in this sample is just a dummy address, you will need to change that. If you need one, feel free to try our service, the developer plan is free and it comes with 3 million free requests.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.