Class: EvmNft

moralis-monorepo / @moralisweb3/evm-utils / EvmNft

Class: EvmNft

@moralisweb3/evm-utils.EvmNft

The EvmNft class is a MoralisData that references to a the NFT of the type; Erc721 or Erc1155

Implements

  • MoralisDataObject

Table of contents

Methods

Accessors

Methods

create

Static create(data, core?): EvmNft

Create a new instance of EvmNft from any valid address input

Example

const nft = EvmNft.create(data);

Parameters

NameTypeDescription
dataEvmNftishthe EvmNftish type
core?MoralisCorethe MoralisCore instance

Returns

EvmNft

an instance of EvmNft


equals

Static equals(valueA, valueB): boolean

Compares two EvmNftish data. verifies that the chain, tokenAddress and owner of values are equal.

Example

 EvmNft.equals(valueA, valueB);

Parameters

NameTypeDescription
valueAEvmNftishthe first EvmNftish data to compare
valueBEvmNftishthe second EvmNftish data to compare

Returns

boolean

true if the values are equal, false otherwise


equals

equals(value): boolean

Compares an EvmNftish data to this EvmNft instance.

Example

nft.equals(value);

Parameters

NameTypeDescription
valueEvmNftishthe value to compare

Returns

boolean

true if the value is equal to the current instance, false otherwise

Implementation of

MoralisDataObject.equals


toJSON

toJSON(): Object

Converts the EvmNft instance to a JSON object.

Example

nft.toJSON()

Returns

Object

JSON object of the EvmNft instance

NameType
tokenAddressstring
chainstring | number
ownerOfundefined | string
blockNumberMintedundefined | string
blockNumberundefined | string
tokenIdstring | number
contractType?EvmNftContractType
tokenUri?string
tokenHash?string
metadata?MoralisDataObjectValue
name?string
symbol?string
lastMetadataSync?Date
lastTokenUriSync?Date
amount?number

Implementation of

MoralisDataObject.toJSON


format

format(): Object

Converts the EvmNft instance to a JSON object.

Example

nft.format()

Returns

Object

JSON object of the EvmNft instance

NameType
tokenAddressstring
chainstring | number
ownerOfundefined | string
blockNumberMintedundefined | string
blockNumberundefined | string
tokenIdstring | number
contractType?EvmNftContractType
tokenUri?string
tokenHash?string
metadata?MoralisDataObjectValue
name?string
symbol?string
lastMetadataSync?Date
lastTokenUriSync?Date
amount?number

Implementation of

MoralisDataObject.format

Accessors

chain

get chain(): EvmChain

Example

nft.chain // EvmChain

Returns

EvmChain

the NFT chain


contractType

get contractType(): undefined | EvmNftContractType

Example

nft.contractType // "ERC721" | "ERC1155"

Returns

undefined | EvmNftContractType

the NFT contract type


tokenAddress

get tokenAddress(): EvmAddress

Example

nft.tokenAddress // EvmAddress

Returns

EvmAddress

the NFT token address


metadata

get metadata(): undefined | MoralisDataObjectValue

Example

nft.metadata
// {
// name: 'Pancake',
// description: 'The dessert series 1',
// image: 'ipfs://QmNQFXCZ6LGzvpMW9Q5PWbCrEnLknQrPwr2r8pbQAgzQ9A/4863BD6B-6C92-4B96-BF80-8020B2F7C3A5.jpeg',
// }

Returns

undefined | MoralisDataObjectValue

the NFT metadata


tokenUri

get tokenUri(): undefined | string

Example

nft.tokenUri // "https://gateway.moralisipfs.com/ipfs/QmajSqgxY3cWBgBeRm38vasJAcTit1kp5EwqVHxszJYgUC/728.json"

Returns

undefined | string

the NFT token URI


tokenHash

get tokenHash(): undefined | string

Example

nft.tokenHash // "QmajSqgxY3cWBgBeRm38vasJAcTit1kp5EwqVHxszJYgUC"

Returns

undefined | string

the NFT token hash


name

get name(): undefined | string

Example

nft.name // "Tether USD"

Returns

undefined | string

the NFT name


symbol

get symbol(): undefined | string

Example

nft.symbol // "USDT"

Returns

undefined | string

the NFT symbol


ownerOf

get ownerOf(): undefined | EvmAddress

Example

nft.ownerOf // EvmAddress

Returns

undefined | EvmAddress

the NFT owner of address


blockNumberMinted

get blockNumberMinted(): undefined | BigNumber

Example

nft.blockNumberMinted // BigNumber

Returns

undefined | BigNumber

the NFT block number minted from


blockNumber

get blockNumber(): undefined | BigNumber

Example

nft.blockNumber // BigNumber

Returns

undefined | BigNumber

the NFT block number


lastMetadataSync

get lastMetadataSync(): undefined | Date

Example

nft.latestMetadataSync // Date

Returns

undefined | Date

the NFT latest metadata sync date


lastTokenUriSync

get lastTokenUriSync(): undefined | Date

Example

nft.latestTokenUriSync // Date

Returns

undefined | Date

the NFT latest token URI sync date


amount

get amount(): undefined | number

Example

nft.amount // 2

Returns

undefined | number

the NFT amount


Did this page help you?