摘要
本篇将介绍体验OpenSea的 NFT 项目的发币与上架流程, 包括:
- 将作品传到IPFS上
- 将元数据传到元数据服务器上
- 在以太坊上部署NFT合约
- 上架OpenSea
OpenSea
目前全球最大的加密数字藏品市场
成立于 2018 年的 OpenSea 是一个基于区块链的全球数字物品买卖市场。OpenSea 的定位是业界领先的去中心化交易所(Decentralized Exchange,DEX),提供点对点(peer-to-peer)的以太坊同质化代币(NFT)交易。该综合平台售卖的数字商品多种多样,包括数字艺术品、加密收藏品、游戏物品等。在 OpenSea 平台上,用户可以与世界上任何一个人进行代币买卖和交换。
作品NFT化
1. 将作品传到IPFS上,获取 URL
(例如 ipfs://QmQg41VNaozk6R1D44882SkpTohXiSLZuQAjVy8Ajr5mpK )
2. 将URL写入元数据json文件中
元数据文件格式
{
"name": "Space Food",
"description": "Astronaut's toothpaste-like food in the space station.",
"image": "ipfs://QmQg41VNaozk6R1D44882SkpTohXiSLZuQAjVy8Ajr5mpK",
"attributes": [
{
"trait_type": "Base",
"value": "jellyfish"
},
{
"display_type": "number",
"trait_type": "Generation",
"value": 2
},
{
"display_type": "boost_percentage",
"trait_type": "Stamina Increase",
"value": 10
},
{
"display_type": "boost_number",
"trait_type": "Aqua Power",
"value": 40
},
{
"display_type": "date",
"trait_type": "birthday",
"value": 1546360800
}
]
}
字段说明:
image: This is the URL to the image of the item. Can be just about any type of image (including SVGs, which will be cached into PNGs by OpenSea, and even MP4s), and can be IPFS URLs or paths. We recommend using a 350 x 350 image. image_data: Raw SVG image data, if you want to generate images on the fly (not recommended). Only use this if you’re not including the image parameter. external_url: This is the URL that will appear below the asset’s image on OpenSea and will allow users to leave OpenSea and view the item on your site. description: A human readable description of the item. Markdown is supported. name: Name of the item. attributes 自定义属性: These are the attributes for the item, which will show up on the OpenSea page for the item. (see below) background_color: Background color of the item on OpenSea. Must be a six-character hexadecimal without a pre-pended #. animation_url: A URL to a multi-media attachment for the item. The file extensions GLTF, GLB, WEBM, MP4, M4V, OGV, and OGG are supported, along with the audio-only extensions MP3, WAV, and OGA. youtube_url: A URL to a YouTube video.
3. 将元数据Json传到元数据服务器上
如果自己有云服务器,都好办;如果没有服务器的话, 可参考以下方法
用IPFS托管元数据Json
缺点是不易扩展,每次修改元数据后都会产生新的CID
https://ipfs.io/ipfs/QmXeypeQzWsbiBbeo7vKuGvaRvrp9j6NGcsPWegZmW8XXy/metadata/1
https://ipfs.io/ipfs/QmXeypeQzWsbiBbeo7vKuGvaRvrp9j6NGcsPWegZmW8XXy/metadata/2
...
https://ipfs.io/ipfs/QmXeypeQzWsbiBbeo7vKuGvaRvrp9j6NGcsPWegZmW8XXy/metadata/12
用Github作为元数据服务器
易于扩展
https://github.com/wcc19840827/opensea-creatures/blob/ryan/dev/res/metadata/1
...
https://github.com/wcc19840827/opensea-creatures/blob/ryan/dev/res/metadata/12
https://raw.githubusercontent.com/wcc19840827/opensea-creatures/ryan/dev/res/metadata/1
4. 在以太坊上部署NFT合约(测试网 rinkeby)
yarn --ignore-engines
== config file `.env` ==
export ALCHEMY_KEY="xxx-xxxx"
export MNEMONIC="xxxx xxxx xxxx ..."
export NETWORK="rinkeby"
source .env
truffle deploy --network rinkeby
source .env
truffle migrate --reset --network rinkeby
==修改 .env中的`NFT_CONTRACT_ADDRESS`为新的合约地址==
export OWNER_ADDRESS="0x4053484960b4c8C2Bde4934B258510b48eea0704"
export NFT_CONTRACT_ADDRESS="0xda4C41b950f06D1Ab3Bf335486254901428F122f"
source .env
node scripts/mint.js
5. 上架OpenSea (测试网)
https://testnets.opensea.io/assets/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1
https://testnets-api.opensea.io/asset/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1/validate/
https://testnets-api.opensea.io/api/v1/asset/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1/?force_update=true
https://testnets.opensea.io/get-listed/step-two
https://testnets.opensea.io/collection/opensea-creatures-keui1ob0sf
6. 在以太坊上部署NFT合约(主网)
使用正式钱包的助记词,且保证得有足够的ETH付邮费
- 部署合约需要至少 0.025 ETH (约330 RMB)
- 之后制造每个NFT,都需要Gas
yarn --ignore-engines
== config file `.env.mainnet` ==
export ALCHEMY_KEY="4cYjJylL-f6i5C0lKJnzhiH_14K23yDj"
export MNEMONIC="XXXXXXXX"
export NETWORK="mainnet"
source .env.mainnet
truffle deploy --network live
source .env.mainnet
truffle migrate --reset --network live
==修改 .env.mainnet 中的`NFT_CONTRACT_ADDRESS`为新的合约地址==
export OWNER_ADDRESS="0x4053484960b4c8C2Bde4934B258510b48eea0704"
export NFT_CONTRACT_ADDRESS="0xda4C41b950f06D1Ab3Bf335486254901428F122f"
source .env.mainnet
node scripts/mint.js
7. 上架OpenSea (主网)
https://opensea.io/assets/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1
https://api.opensea.io/asset/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1/validate/
https://api.opensea.io/api/v1/asset/0xda4C41b950f06D1Ab3Bf335486254901428F122f/1/?force_update=true
https://opensea.io/get-listed/step-two
https://opensea.io/collection/opensea-creatures-keui1ob0sf
往期精彩回顾:
-
区块链知识系列
-
密码学系列
-
零知识证明系列
-
共识系列
-
公链调研系列
-
比特币系列
-
以太坊系列
-
EOS系列
-
Filecoin系列
-
联盟链系列
-
Fabric系列
-
智能合约系列
-
Token系列
|