Skip to main content

Class: EvmNft

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

Class: EvmNft

@moralisweb3/common-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

Constructors

Methods

create

Static create(data): EvmNft

Create a new instance of EvmNft from any valid address input

Example

const nft = EvmNft.create(data);

Parameters

NameTypeDescription
dataEvmNftishthe EvmNftish type

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


parse

Static parse(data): EvmNftData

Parameters

NameType
dataEvmNftInput

Returns

EvmNftData


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


format

format(): Object

Deprecated

This method will be removed soon. To format the value, use one of the properties.

Returns

Object

NameType
amount?number
blockNumberundefined | string
blockNumberMintedundefined | string
chainstring
contractType?string
lastMetadataSync?Date
lastTokenUriSync?Date
mediaundefined | { category?: EvmNftMediaCategory ; chain: string ; mediaCollection?: { high: EvmNftMediaItem ; low: EvmNftMediaItem ; medium: EvmNftMediaItem } ; mimetype?: string ; originalMediaUrl?: string ; parentHash?: string ; status?: EvmNftMediaStatus ; updatedAt?: Date }
metadata?MoralisDataObjectValue
name?string
ownerOfundefined | string
possibleSpamboolean
symbol?string
tokenAddressstring
tokenHash?string
tokenIdstring | number
tokenUri?string

Implementation of

MoralisDataObject.format


toJSON

toJSON(): Object

Converts the EvmNft instance to a JSON object.

Example

nft.toJSON()

Returns

Object

JSON object of the EvmNft instance

NameType
amount?number
blockNumberundefined | string
blockNumberMintedundefined | string
chainstring
contractType?string
lastMetadataSync?Date
lastTokenUriSync?Date
mediaundefined | { category?: EvmNftMediaCategory ; chain: string ; mediaCollection?: { high: EvmNftMediaItem ; low: EvmNftMediaItem ; medium: EvmNftMediaItem } ; mimetype?: string ; originalMediaUrl?: string ; parentHash?: string ; status?: EvmNftMediaStatus ; updatedAt?: Date }
metadata?MoralisDataObjectValue
name?string
ownerOfundefined | string
possibleSpamboolean
symbol?string
tokenAddressstring
tokenHash?string
tokenIdstring | number
tokenUri?string

Implementation of

MoralisDataObject.toJSON

Accessors

amount

get amount(): undefined | number

Example

nft.amount // 2

Returns

undefined | number

the NFT amount


blockNumber

get blockNumber(): undefined | BigNumber

Example

nft.blockNumber // BigNumber

Returns

undefined | BigNumber

the NFT block number


blockNumberMinted

get blockNumberMinted(): undefined | BigNumber

Example

nft.blockNumberMinted // BigNumber

Returns

undefined | BigNumber

the NFT block number minted from


chain

get chain(): EvmChain

Example

nft.chain // EvmChain

Returns

EvmChain

the NFT chain


contractType

get contractType(): undefined | string

Example

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

Returns

undefined | string

the NFT contract type


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


media

get media(): undefined | EvmNftMedia

Example

nft.media // EvmNftMedia

Returns

undefined | EvmNftMedia

the processed media of the NFT


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


name

get name(): undefined | string

Example

nft.name // "Tether USD"

Returns

undefined | string

the NFT name


ownerOf

get ownerOf(): undefined | EvmAddress

Example

nft.ownerOf // EvmAddress

Returns

undefined | EvmAddress

the NFT owner of address


possibleSpam

get possibleSpam(): boolean

Example

transfer.possibleSpam // true

Returns

boolean

possibility of the token being a spam token


result

get result(): EvmNftData

Returns

EvmNftData


symbol

get symbol(): undefined | string

Example

nft.symbol // "USDT"

Returns

undefined | string

the NFT symbol


tokenAddress

get tokenAddress(): EvmAddress

Example

nft.tokenAddress // EvmAddress

Returns

EvmAddress

the NFT token address


tokenHash

get tokenHash(): undefined | string

Example

nft.tokenHash // "QmajSqgxY3cWBgBeRm38vasJAcTit1kp5EwqVHxszJYgUC"

Returns

undefined | string

the NFT token hash


tokenId

get tokenId(): string | number

Example

nft.tokenId // '1234'

Returns

string | number

the token id


tokenUri

get tokenUri(): undefined | string

Example

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

Returns

undefined | string

the NFT token URI

Constructors

constructor

new EvmNft(data)

Parameters

NameType
dataEvmNftInput