How can we get transaction information

  1. I have run a code in solidity, then I minted a NFT and did the transaction using metamask.

  2. After successful transaction I got transaction receipt in Remix terminal.

  3. Now I want that same information in my MongoDB.

then what can I do ?

you can sync the events specific to that mint

https://docs.moralis.io/moralis-dapp/automatic-transaction-sync/smart-contract-events

I am using sync, but after sync I am only able to create table in database, but not able to fetch the transaction

Can you check if there are any errors in the database logs which are related to the event sync.

As UI interface has changes I am not able to open the database for the server created.

If you open the server settings you can find the option here.

You can also use the legacy UI if you still can’t open it.

1 Like

I am not getting any error.

Did any events emit from the contract after adding the event sync?

Can you share the event ABI, chain and contract address which you used to add the sync.

Topic - Approval (address, address, uint256)
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”
}

address - 0xf6b0599780bbf43489bfc863A3d6F194119bCdD2

what is the server url?

What is the chain name?

Rinkeby Testnet Network

There are no events for this contract address. Thats the reason it did not sync any.
https://rinkeby.etherscan.io/address/0xf6b0599780bbf43489bfc863A3d6F194119bCdD2#events

But I have transactions, then how can I get events ?

https://s13raf28z2ju.usemoralis.com:2053/server

As per your contract code, Approval events are emitted in the _approve function. So when you call the _approve function you get a new Approval event.

What should I do now ?

As per the etherscan both your transactions are failed due to less gas. Maybe run a new transaction with enough gas and add an emit event in the function which you are calling.

// SPDX-License-Identifier: Unlicense

pragma solidity ^0.8.4;

import “@openzeppelin/[email protected]/token/ERC721/extensions/ERC721Enumerable.sol”;

import “@openzeppelin/[email protected]/token/ERC721/extensions/ERC721URIStorage.sol”;

import “@openzeppelin/[email protected]/token/ERC721/extensions/IERC721Metadata.sol”;

import “@openzeppelin/[email protected]/token/ERC721/ERC721.sol”;

import “@openzeppelin/[email protected]/utils/math/SafeMath.sol”;

contract trans is ERC721, ERC721Enumerable, ERC721URIStorage{

    function _beforeTokenTransfer(address from, address to, uint256 tokenId)

    internal

    override(ERC721, ERC721Enumerable)

{

    super._beforeTokenTransfer(from, to, tokenId);

}

function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage){

    super._burn(tokenId);

}

function supportsInterface(bytes4 interfaceId)

    public

    view

    override(ERC721, ERC721Enumerable)

    returns (bool)

{

    return super.supportsInterface(interfaceId);

}

function tokenURI(uint256 tokenId)

    public

    view

    override(ERC721, ERC721URIStorage)

    returns (string memory)

{

    return super.tokenURI(tokenId);

}

    constructor() ERC721("YTMinter", "YTM")  {}

    function get() public payable {

           string memory _link = "https://ipfs.io/ipfs/QmRsYWdpykpcsiC1YELHnJDepAdk1kqpg9rQ6ipEzYRywA";

           mint(_link);

    }

    function mint(string memory _uri) public {

            uint256 mintIndex = totalSupply();

            _safeMint(msg.sender, mintIndex);

            _setTokenURI(mintIndex, _uri);

    }

    //function name() external view returns (string name);

}

where to add emit what to write ?

there are 3 transactions out of which 1 is done properly, then that transaction should be visble.