你好,请选择
语言:
关闭

Display an NFT in a scene

You can display an NFT (Non-Fungible Token) that you own in your Decentraland scenes. A glowing badge will appear above the NFT to certify that you indeed own it.

Note: The NTF’s image data is taken from Opensea, based on the token’s contract and id. Currently, Opensea only supports 2D tokens such as CriptoKitties or CriptoPunks. So 3D tokens currently can’t be displayed in this way.

Add an NFT

Add an NFTShape component to an entity to display a 2D token in your scene.

// create entity
const nft = new Entity()

// position entity
nft.add(new Transform({
  position: new Vector(1, 1.2, 1)
  }))

// add an NFTShape, instanced with a token contract and token id
nft.add(new NFTShape("0x06012c8cf97bead5deae237070f9587f8e7a266d", "475577"))

// add entity to engine
engine.addEntity(nft)

The NFTShape component must be instanced with two parameters:

  • The contract of the token (for example, the CryptoKitties contract)
  • The id of the specific token you own

When the token is displayed, it’s shown as a plane object. Its texture is shadeless, like a basic material.

Token certification

When using the NFTShape component, the engine automatically runs a verification. The same Ethereum wallet that owns the LAND tokens where the scene is deployed must also own the token.

If you don’t own the token, the image isn’t displayed in the scene.

This verification is carried out by users loading your scene, every time the entity with the NFTShape component is added to the engine.

Above the image of the token, we display a badge that certifies its authenticity. The badge glows in a pulsating pattern, providing a stamp that is difficult to falsify.

Note: If you want to display a token that you don’t own, or prefer to display it without the authenticity badge, you can otherwise obtain an NFT image from Opensea’s API and set that as a texture for a material. Then you can use that material on any primitive object in the scene.