[SOLVED] Running addEvents.js returns false

I don’t know, you can try with the other number

just did, it’s still failing

you can try to add the event sync from admin interface

I’ve been trying, but it’s not accepting the abi for some reason. I’ll try it out again

what is the abi that you are using?

the example of one event’s abi is

{
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "seller",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "NFTListed",
      "type": "event"
    },

I’ve tried pasting the entire abi, part of the abi, it still does not allow me to access the Topic

this is all you paste as the ABI?

no, I’ve tried pasting the entire abi, part of the abi, it still does not allow me to access the Topic

"abi": [
    {
      "inputs": [],
      "stateMutability": "nonpayable",
      "type": "constructor"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "MarsKetplace__AlreadyListed",
      "type": "error"
    },
    {
      "inputs": [],
      "name": "MarsKetplace__NotApproved",
      "type": "error"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "MarsKetplace__NotListed",
      "type": "error"
    },
    {
      "inputs": [],
      "name": "MarsKetplace__NotOwner",
      "type": "error"
    },
    {
      "inputs": [],
      "name": "MarsKetplace__PriceCantBeZero",
      "type": "error"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "MarsKetplace__PriceNotMet",
      "type": "error"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "buyer",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "NFTBought",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "NFTDeleted",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "seller",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "NFTListed",
      "type": "event"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "buyNFT",
      "outputs": [],
      "stateMutability": "payable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "cancelListing",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "getBalance",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "getListing",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint256",
              "name": "price",
              "type": "uint256"
            },
            {
              "internalType": "address",
              "name": "seller",
              "type": "address"
            }
          ],
          "internalType": "struct MarsKetplace.Listing",
          "name": "",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "price",
          "type": "uint256"
        }
      ],
      "name": "listNft",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "newPrice",
          "type": "uint256"
        }
      ],
      "name": "updateNFTPrice",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "withdrawSales",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],

Try with the legacy interface: https://legacybackup.moralis.io/, the legacy interface will not stay for long.

you need only the abi for the event that you want to sync, but in the right format

the interface says ā€œPaste the whole ABI or just the event object of the contractā€ so I’ve tried both options, and still the same result.

The format I use is json, is it supposed to be something else?

it should have the proper start and ending, not random , or other things like

Could you give me an example ?
It’s the first time I have to do this, so I’ve tried removing the abi in front, removing brackets, etc… but it doesnt work

    anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "nftAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "uint256",
          "name": "tokenId",
          "type": "uint256"
        }
      ],
      "name": "NFTDeleted",
      "type": "event"

That’s what appears in the .json file that has the abi in it, I’m not sure how to format it

the syntax is different when you use it in the admin interface vs when you use it from a script to add an event sync

when you add it from the interface you will need [ at the beginning and ] at the end, and the abi only for your specific event should be enough inside those [ ]

nothing more, no extra , no other things before and after

alright, so [ inputs, name, type] only as data inside those brackets, correct?

no, you have to update this one a little, add [ ], remove a , and that should be all

ooook, finally got it, thank you!!! now it allows me to access the topic and save it.
I’ll keep you updated on how it goes now

1 Like

Thanks again for your help! running mint-and-list correctly lists my NFT and I can see it on the dashboard.

I’ll keep looking at this eth_blockNumber counter running wild, there may be some event listener stuck on a loop or something. Probably has to do with my code, but at least I can move forward with my dapp.
I’ll also investigate why the script is not working, just 'cause.

Thanks again, you were very helpful :slight_smile:

1 Like