Error using native.getNFTTransfersByBlock and native.getBlock

Hi,
After effectively calling mint on my contract the response comes back with an object containing blockHash, which I tried to use to get the token recently minted by calling these functions in separate tests.

getBlock gives this error:

getNFTTransfersByBlock:

Regards,
Fch

1 Like

Hey @nosh247, hope you are great!

Could you please share the function that sent the parameters to the getBlock function? the next console message refers to an Error with an Object, so maybe you are sending an object instead the correct arguments.

Carlos Z

1 Like

Hi, Im doing awesome and i love this product! First I call the mint function, iโ€™ve been following this page suggestions:
https://docs.moralis.io/moralis-server/web3-sdk/native

let web3 = await Moralis.Web3.enable();
    const contract = new web3.eth.Contract(smartContractAbi, contractAddress);

    let receipt = await contract.methods
      .mint(1)
      .send({ from: user.attributes.ethAddress, value: 8620580000000000 })
      .then((response) => {
        console.log(response);
        updateNfts();
        getRecentMint(response.blockNumber);
      })
      .catch((err) => setError(err.message));

after that is done and i get the response, i get the blockNumber and pass it to my โ€œverificationโ€ method, below getNFTTransfersByBlock test:

const getRecentMint = async (blockNumber) => {
    console.log("get recent mint:", blockNumber);
    let options = {
      chain: "rinkeby",
      block_number_or_hash: blockNumber,
    };
    await Moralis.Web3API.native
      .getNFTTransfersByBlock(options)
      .then((response) => {
        console.log(response);
      })
      .catch((err) => console.log(err));
  };

getBlock test:

const getRecentMint = async (blockNumber) => {
    console.log("get recent mint:", blockNumber);
    let options = {
      chain: "rinkeby",
      block_number_or_hash: blockNumber,
    };
    await Moralis.Web3API.native
      .getBlock(options)
      .then((response) => {
        console.log(response);
      })
      .catch((err) => console.log(err));
  };

regards,
Fch

I think that it takes some time until latest blocks are available to query in web3api, you can query a speedy node if you want instant information about latest block.