Streams API doesn't send logs in a event

I’ve created stream and received several events to my endpoint. Some of events contain logs and some don’t contain, but transactions itselfs contain. E.g:

Stream:

{"id":"uuid","webhookUrl":"my-endpoint","description":"Test","tag":"1","demo":false,"topic0":null,"allAddresses":false,"includeNativeTxs":true,"includeContractLogs":true,"includeInternalTxs":true,"abi":null,"advancedOptions":null,"chainIds":["0x5"],"status":"active","statusMessage":"Stream is active"}

Tx with logs is available by the link.
Web hook:

{
  "confirmed": false,
  "chainId": "0x5",
  "abi": [],
  "streamId": "6e74ccb4-ca3e-4a51-a444-58a0c846be68",
  "tag": "1",
  "retries": 0,
  "block": {
    "number": "8037049",
    "hash": "0x6d68b99ebacbff7ae41fc53347784fc35a59b9c950ce9cefce1540c8f3a78f32",
    "timestamp": "1669654500"
  },
  "logs": [
    {
      "logIndex": "95",
      "transactionHash": "0xf9ea006e140708ec8ea2f6e03bec557d4b99d031aef0e6ec3075623c89d9a1ba",
      "address": "0x43b2a1e1e2f9eedd4a5276cba2da9b4ed371d79f",
      "data": "0x",
      "topic0": "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
      "topic1": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "topic2": "0x000000000000000000000000e4f0ff4641f3c99de342b06c06414d94a585effb",
      "topic3": null
    }
  ],
  "txs": [
    {
      "hash": "0xf9ea006e140708ec8ea2f6e03bec557d4b99d031aef0e6ec3075623c89d9a1ba",
... skipped ...
}
  ],
  "txsInternal": [],
  "erc20Transfers": [],
  "erc20Approvals": [],
  "nftApprovals": {
    "ERC1155": [],
    "ERC721": []
  },
  "nftTransfers": []
}

The next transaction also contains logs, but I did not receive it:

{
  "confirmed": false,
  "chainId": "0x5",
  "abi": [],
  "streamId": "6e74ccb4-ca3e-4a51-a444-58a0c846be68",
  "tag": "1",
  "retries": 0,
  "block": {
    "number": "8037250",
    "hash": "0xb68775acd7fe3d8589c7151207f33729d8ec4acf5ff4c23348a1c985af8769a6",
    "timestamp": "1669657320"
  },
  "logs": [],
  "txs": [
    {
      "hash": "0x758e553eccdd71884500099683768775cca6787121415ac6cb824dff903dcb23",
      ... skipped ...
    }
  ],
  "txsInternal": [],
  "erc20Transfers": [],
  "erc20Approvals": [],
  "nftApprovals": {
    "ERC1155": [],
    "ERC721": []
  },
  "nftTransfers": []
}

What is the config that you used for that stream?

You can get it with the swagger interface

it looks like this is the stream config:

  {
      "id": "6e74ccb4-ca3e-4a51-a444-58a0c846be68",
      "webhookUrl": "wehbook_url",
      "description": "Test",
      "tag": "1",
      "demo": false,
      "topic0": null,
      "allAddresses": false,
      "includeNativeTxs": true,
      "includeContractLogs": true,
      "includeInternalTxs": true,
      "abi": null,
      "advancedOptions": null,
      "chainIds": [
        "0x5"
      ],
      "status": "active",
      "statusMessage": "Stream is active"
    }
  ]

you received this log on the first transaction

 "logs": [
    {
      "logIndex": "95",
      "transactionHash": "0xf9ea006e140708ec8ea2f6e03bec557d4b99d031aef0e6ec3075623c89d9a1ba",
      "address": "0x43b2a1e1e2f9eedd4a5276cba2da9b4ed371d79f",
      "data": "0x",
      "topic0": "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
      "topic1": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "topic2": "0x000000000000000000000000e4f0ff4641f3c99de342b06c06414d94a585effb",
      "topic3": null
    }
  ],

because the address that you added to that stream matched the topic2 of this event.

the other events from the other 2 transactions don’t match in topics the address that was added to the stream

we don’t have an option now to include all the logs for a transaction, we will work on getting a solution for this use case

@cryptokid thank you for the explanation! Could you please clarify alos: will adding ABI to the stream help me get other logs?

if you add the abi and topics specific to the logs/events that you want and you add the contract address to the list of addresses to that stream then you will get those logs

you are interested in all the possible events or only in specific events/logs?

Generally, I’m interested in all logs from the specified transaction. It’s much more useful for me, because I only need to change code (which happens regularly) and do not need to update ABIs and related things in the Moralis API.

we also released a new endpoint in the web3api now
https://deep-index.moralis.io/api-docs-2.1/#/Transaction/getWalletTransactionsVerbose

that should give the transactions and logs for a wallet address, in case that this also helps you

Thank you! I think tx receipt will be enough for me. I do not want to poll API for getting information.

I’ve tried to specify certain ABI, and it still doesn’t sent me logs:

 {
  "result": [
    {
      "id": "6e74ccb4-ca3e-4a51-a444-58a0c846be68",
      "webhookUrl": "https://webhook.site/8945f66f-78f3-4524-a26d-f6ad96a06ac7",
      "description": "Test",
      "tag": "1",
      "demo": false,
      "topic0": [
        "Approval(address,address,uint256)",
        "OwnershipTransferred(address,address)",
        "ApprovalForAll(address,address,bool)",
        "Transfer(address,address,uint256)"
      ],
      "allAddresses": false,
      "includeNativeTxs": true,
      "includeContractLogs": true,
      "includeInternalTxs": true,
      "triggers": [],
      "abi": [
        {
          "anonymous": false,
          "inputs": [
            {
              "indexed": true,
              "internalType": "address",
              "name": "owner",
              "type": "address"
            },
            {
              "indexed": true,
              "internalType": "address",
              "name": "approved",
              "type": "address"
            },
            {
              "indexed": true,
              "internalType": "uint256",
              "name": "tokenId",
              "type": "uint256"
            }
          ],
          "name": "Approval",
          "type": "event"
        },
        {
          "anonymous": false,
          "inputs": [
            {
              "indexed": true,
              "internalType": "address",
              "name": "owner",
              "type": "address"
            },
            {
              "indexed": true,
              "internalType": "address",
              "name": "operator",
              "type": "address"
            },
            {
              "indexed": false,
              "internalType": "bool",
              "name": "approved",
              "type": "bool"
            }
          ],
          "name": "ApprovalForAll",
          "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": "address",
              "name": "from",
              "type": "address"
            },
            {
              "indexed": true,
              "internalType": "address",
              "name": "to",
              "type": "address"
            },
            {
              "indexed": true,
              "internalType": "uint256",
              "name": "tokenId",
              "type": "uint256"
            }
          ],
          "name": "Transfer",
          "type": "event"
        }
      ],
      "advancedOptions": null,
      "chainIds": [
        "0x5"
      ],
      "status": "active",
      "statusMessage": "Stream is active"
    }
  ],
  "total": 1
}

I did a transaction: https://goerli.etherscan.io/tx/0x758e553eccdd71884500099683768775cca6787121415ac6cb824dff903dcb23#eventlog
There is one log record, Transfer(address,address,uint256)

But I got event w/o log:

{
  "confirmed": true,
  "chainId": "0x5",
  "abi": [],
  "streamId": "6e74ccb4-ca3e-4a51-a444-58a0c846be68",
  "tag": "1",
  "retries": 0,
  "block": {
    "number": "8037250",
    "hash": "0xb68775acd7fe3d8589c7151207f33729d8ec4acf5ff4c23348a1c985af8769a6",
    "timestamp": "1669657320"
  },
  "logs": [],
  "txs": [
    {
      "hash": "0x758e553eccdd71884500099683768775cca6787121415ac6cb824dff903dcb23",
      "gas": "122826",
      "gasPrice": "7475695440",
      "nonce": "11",
      "input": "0x94bf804d00000000000000000000000000000000000000000000000000000000000000020000000000000000000000005abe16bbe0547a4b36f99ca7b383e72163504845",
      "transactionIndex": "60",
      "fromAddress": "0xe4f0ff4641f3c99de342b06c06414d94a585effb",
      "toAddress": "0xef074320e6ac28acb0c6b52fd0bd209d9ddc5a0b",
      "value": "0",
      "type": "2",
      "v": "0",
      "r": "89672898336118424119055645771514138675689670971748914596232702403777655652766",
      "s": "48478520085549639400589575602177433831848113036728183006637206047694617341362",
      "receiptCumulativeGasUsed": "13706247",
      "receiptGasUsed": "81094",
      "receiptContractAddress": null,
      "receiptRoot": null,
      "receiptStatus": "1"
    }
  ],
  "txsInternal": [],
  "erc20Transfers": [],
  "erc20Approvals": [],
  "nftApprovals": {
    "ERC1155": [],
    "ERC721": []
  },
  "nftTransfers": []
}

Could you please take a look at this?

Did you add the contract address to the list of addresses for that stream?

No, I didn’t. I forget to do it… Thank you and sorry for bothering.

@cryptokid now it works as I expected. Thanks for the help.

1 Like