nft-blockchain
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNFT and Blockchain in Decentraland
Decentraland 中的 NFT 与区块链
Display NFT Artwork
展示 NFT 艺术作品
Use to show an NFT in a decorative picture frame. Provide the NFT URN and choose a frame style. The image is loaded automatically from the NFT's metadata (fetched through Decentraland's OpenSea proxy, ) — any NFT that OpenSea supports can be displayed, across multiple chains.
NftShapeopensea.decentraland.orgNFT URN format:
urn:decentraland:<chain>:<contractStandard>:<contractAddress>:<tokenId>- Example:
urn:decentraland:ethereum:erc721:0x06012c8cf97bead5deae237070f9587f8e7a266d:558536 - supported values (forwarded verbatim to the OpenSea v2 API; unrecognized chains are rejected):
<chain>,ethereum,matic,klaytn,bsc,arbitrum,arbitrum_nova,avalanche,optimism,solana,base,blast.zora - is typically
<contractStandard>. The image is served from the OpenSea response, so contracts OpenSea indexes aserc721also resolve.erc1155
使用 在装饰性画框中显示 NFT。提供 NFT URN 并选择画框样式。图像会根据 NFT 的元数据自动加载(通过 Decentraland 的 OpenSea 代理 获取)——OpenSea 支持的任何 NFT 均可跨多条链显示。
NftShapeopensea.decentraland.orgNFT URN 格式:
urn:decentraland:<chain>:<contractStandard>:<contractAddress>:<tokenId>- 示例:
urn:decentraland:ethereum:erc721:0x06012c8cf97bead5deae237070f9587f8e7a266d:558536 - 支持的值(会原样传递给 OpenSea v2 API;无法识别的链将被拒绝):
<chain>、ethereum、matic、klaytn、bsc、arbitrum、arbitrum_nova、avalanche、optimism、solana、base、blast。zora - 通常为
<contractStandard>。图像由 OpenSea 响应提供,因此被 OpenSea 索引为erc721的合约也能够解析。erc1155
Available Frame Styles
可用画框样式
typescript
NftFrameType.NFT_CLASSIC // Simple classic frame
NftFrameType.NFT_BAROQUE_ORNAMENT // Ornate baroque
NftFrameType.NFT_DIAMOND_ORNAMENT // Diamond pattern
NftFrameType.NFT_MINIMAL_WIDE // Minimal wide border
NftFrameType.NFT_MINIMAL_GREY // Minimal grey border
NftFrameType.NFT_BLOCKY // Pixelated/blocky
NftFrameType.NFT_GOLD_EDGES // Gold edge trim
NftFrameType.NFT_GOLD_CARVED // Carved gold
NftFrameType.NFT_GOLD_WIDE // Wide gold border
NftFrameType.NFT_GOLD_ROUNDED // Rounded gold
NftFrameType.NFT_METAL_MEDIUM // Medium metal
NftFrameType.NFT_METAL_WIDE // Wide metal
NftFrameType.NFT_METAL_SLIM // Slim metal
NftFrameType.NFT_METAL_ROUNDED // Rounded metal
NftFrameType.NFT_PINS // Pinned to wall
NftFrameType.NFT_MINIMAL_BLACK // Minimal black
NftFrameType.NFT_MINIMAL_WHITE // Minimal white
NftFrameType.NFT_TAPE // Taped to wall
NftFrameType.NFT_WOOD_SLIM // Slim wood
NftFrameType.NFT_WOOD_WIDE // Wide wood
NftFrameType.NFT_WOOD_TWIGS // Twig/branch wood
NftFrameType.NFT_CANVAS // Canvas style
NftFrameType.NFT_NONE // No frametypescript
NftFrameType.NFT_CLASSIC // Simple classic frame
NftFrameType.NFT_BAROQUE_ORNAMENT // Ornate baroque
NftFrameType.NFT_DIAMOND_ORNAMENT // Diamond pattern
NftFrameType.NFT_MINIMAL_WIDE // Minimal wide border
NftFrameType.NFT_MINIMAL_GREY // Minimal grey border
NftFrameType.NFT_BLOCKY // Pixelated/blocky
NftFrameType.NFT_GOLD_EDGES // Gold edge trim
NftFrameType.NFT_GOLD_CARVED // Carved gold
NftFrameType.NFT_GOLD_WIDE // Wide gold border
NftFrameType.NFT_GOLD_ROUNDED // Rounded gold
NftFrameType.NFT_METAL_MEDIUM // Medium metal
NftFrameType.NFT_METAL_WIDE // Wide metal
NftFrameType.NFT_METAL_SLIM // Slim metal
NftFrameType.NFT_METAL_ROUNDED // Rounded metal
NftFrameType.NFT_PINS // Pinned to wall
NftFrameType.NFT_MINIMAL_BLACK // Minimal black
NftFrameType.NFT_MINIMAL_WHITE // Minimal white
NftFrameType.NFT_TAPE // Taped to wall
NftFrameType.NFT_WOOD_SLIM // Slim wood
NftFrameType.NFT_WOOD_WIDE // Wide wood
NftFrameType.NFT_WOOD_TWIGS // Twig/branch wood
NftFrameType.NFT_CANVAS // Canvas style
NftFrameType.NFT_NONE // No frameCheck Player Wallet
检查玩家钱包
Use from to get the player's Ethereum address via . Always check before any blockchain interaction -- guest players don't have a connected wallet.
getPlayer()@dcl/sdk/src/playersplayer.userIdisGuest使用 中的 ,通过 获取玩家的 Ethereum 地址。在执行任何区块链交互之前,始终检查 ——访客玩家没有连接钱包。
@dcl/sdk/src/playersgetPlayer()player.userIdisGuestSigned Requests
签名请求
Use from to send authenticated requests to a backend. It automatically injects signed identity headers (ADR-44) that your backend verifies — you do not build or pass them yourself.
signedFetch~system/SignedFetch- Signature: .
signedFetch({ url, init: { method?, headers?, body? } }) - Response is ;
{ ok, status, statusText, headers, body }is a string — callbody(there is noJSON.parse(response.body))..json() - It does not require prior player interaction (unlike restricted actions).
- Need only the signed headers for a library that does its own fetching? Use from the same module — it returns
getHeaders({ url, init? }).{ headers }
使用 中的 向后端发送经过身份验证的请求。它会自动注入签名身份标头(ADR-44),由你的后端进行验证——无需自行构建或传递这些标头。
~system/SignedFetchsignedFetch- 签名:。
signedFetch({ url, init: { method?, headers?, body? } }) - 响应为 ;
{ ok, status, statusText, headers, body }是字符串——请调用body(没有JSON.parse(response.body))。.json() - 它不需要事先与玩家交互(与受限操作不同)。
- 某个库会自行执行请求,但只需要签名标头时?使用同一模块中的 ——它返回
getHeaders({ url, init? })。{ headers }
Smart Contract Interaction
智能合约交互
For direct smart contract calls, use with from . Store ABIs in separate files, create a contract instance via , then call read (no gas) or write (requires gas, prompts user to sign) functions.
eth-connectcreateEthereumProvider@dcl/sdk/ethereum-providerContractFactorybash
npm install eth-connectRead operations (view/pure functions) don't require gas. Write operations prompt the player to sign and require gas.
Wrap all async blockchain calls in . Handle errors gracefully — blockchain operations can fail (rejected by user, insufficient gas, network issues).
executeTask(async () => { ... })对于直接的智能合约调用,使用 ,并结合 中的 。将 ABI 存储在单独的文件中,通过 创建合约实例,然后调用读取(无需 gas)或写入(需要 gas,会提示用户签名)函数。
eth-connect@dcl/sdk/ethereum-providercreateEthereumProviderContractFactorybash
npm install eth-connect读取操作(view/pure 函数)不需要 gas。写入操作会提示玩家签名并需要 gas。
将所有异步区块链调用包装在 中。妥善处理错误——区块链操作可能会失败(用户拒绝、gas 不足、网络问题)。
executeTask(async () => { ... })Gas Price and Balance
Gas 价格与余额
Use and from to check current gas prices and account ETH balances.
requestManager.eth_gasPrice()requestManager.eth_getBalance()eth-connect使用 中的 和 查询当前 gas 价格和账户 ETH 余额。
eth-connectrequestManager.eth_gasPrice()requestManager.eth_getBalance()Custom RPC Calls
自定义 RPC 调用
Use from for low-level Ethereum RPC calls not covered by eth-connect helpers.
sendAsync~system/EthereumController使用 中的 执行 辅助函数未涵盖的低级 Ethereum RPC 调用。
~system/EthereumControllersendAsynceth-connectOpening External URLs / NFT Dialogs
打开外部 URL / NFT 弹窗
Use and from to open external links and NFT detail views.
openExternalUrlopenNftDialog~system/RestrictedActions使用 中的 和 打开外部链接和 NFT 详情视图。
~system/RestrictedActionsopenExternalUrlopenNftDialogTesting with Sepolia
使用 Sepolia 测试
For development, use the Sepolia testnet: set MetaMask to Sepolia, get test ETH from a faucet, deploy contracts to Sepolia. Contract addresses differ between mainnet and testnet.
开发时,使用 Sepolia 测试网:将 MetaMask 设置为 Sepolia,从水龙头(faucet)获取测试 ETH,并将合约部署到 Sepolia。合约地址在主网和测试网之间有所不同。
dcl-crypto-toolkit (Higher-Level API)
dcl-crypto-toolkit(高级 API)
For common blockchain operations, use instead of raw . It provides a cleaner API for the most frequent tasks.
dcl-crypto-toolkiteth-connectbash
npm install dcl-crypto-toolkitImport: . Modules: , , , , , , , . There is NO top-level .
import * as crypto from 'dcl-crypto-toolkit'ethereummanacurrencynftmarketplaceserviceswearablecontractcrypto.signMessageCapabilities:
- MANA operations: send, check balance (/
crypto.mana.send/.myBalance).balance - ERC20 tokens: send, check balance, check/set allowance ()
crypto.currency.* - ERC721/NFT: check tokens held (token gating), transfer, approval management ()
crypto.nft.* - Marketplace: buy (), sell (
executeOrder), cancel (createOrder), check authorization (cancelOrder)crypto.marketplace.* - Sign message: sign EIP-712 typed data with player wallet ()
crypto.ethereum.signMessageAdvanced()
对于常见的区块链操作,使用 而不是原始的 。它为最常用的任务提供了更简洁的 API。
dcl-crypto-toolkiteth-connectbash
npm install dcl-crypto-toolkit导入:。模块包括:、、、、、、、。不存在顶层 。
import * as crypto from 'dcl-crypto-toolkit'ethereummanacurrencynftmarketplaceserviceswearablecontractcrypto.signMessage能力:
- MANA 操作: 发送、检查余额(/
crypto.mana.send/.myBalance).balance - ERC20 代币: 发送、检查余额、检查/设置 allowance()
crypto.currency.* - ERC721/NFT: 检查持有的代币(token gating)、转移、approval 管理()
crypto.nft.* - Marketplace: 买入()、卖出(
executeOrder)、取消(createOrder)、检查授权(cancelOrder)crypto.marketplace.* - 签名消息: 使用玩家钱包签署 EIP-712 类型化数据()
crypto.ethereum.signMessageAdvanced()
Token Gating
代币门控
By NFT ownership: Use — returns whether the player holds tokens of that contract. Omit to check any token of the contract. Grant or deny access on the result.
crypto.nft.checkTokens(contractAddress, tokenIds?)tokenIdsBy MANA balance: Check (or for other ERC20 tokens) to gate access based on holdings.
crypto.mana.myBalance()crypto.currency.balance(contractAddress, address)按 NFT 所有权: 使用 ——返回玩家是否持有该合约的代币。省略 可检查该合约的任意代币。根据结果授予或拒绝访问权限。
crypto.nft.checkTokens(contractAddress, tokenIds?)tokenIds按 MANA 余额: 使用 检查余额(或使用 检查其他 ERC20 代币),并根据持仓量对访问权限进行门控。
crypto.mana.myBalance()crypto.currency.balance(contractAddress, address)Quick Decision Guide
快速决策指南
| Task | Use |
|---|---|
| Send MANA | |
| Check own MANA balance | |
| Check any address's MANA balance | |
| Send any ERC20 token | |
| Check ERC20 balance | |
| Transfer an NFT | |
| Check NFT ownership / token gating | |
| Buy from marketplace | |
| List NFT for sale | |
| Sign a message | |
| Custom smart contract | |
| Authenticated API call | |
For full code examples and implementation patterns, including the dcl-crypto-toolkit library API, see '{baseDir}/references/blockchain-patterns.md'.
| 任务 | 使用 |
|---|---|
| 发送 MANA | |
| 检查自己的 MANA 余额 | |
| 检查任意地址的 MANA 余额 | |
| 发送任意 ERC20 代币 | |
| 检查 ERC20 余额 | |
| 转移 NFT | |
| 检查 NFT 所有权 / 代币门控 | |
| 从 Marketplace 购买 | |
| 挂牌出售 NFT | |
| 签名消息 | |
| 自定义智能合约 | |
| 经过身份验证的 API 调用 | |
有关完整代码示例和实现模式(包括 dcl-crypto-toolkit 库 API),请参阅 '{baseDir}/references/blockchain-patterns.md'。