OpenSeaにトークンを掲載する方法
OpenSeaのチュートリアルをやってみる。
OpenSea Developer Tutorial
Simple tutorial for a customizable marketplace for buying and selling on OpenSea
SUGGEST EDITS
Want an instant, customizable marketplace for your game items, collectibles, or other ERC-721 assets? You’ve come to the right place.
This tutorial will show you how to go from start to finish building a storefront for your items. We’ll walk you through structuring your ERC721 contract and off-chain metadata, viewing your items on OpenSea, and testing out the auction flow for your items.
By the end of this tutorial, you’ll know how to integrate with OpenSea and create a custom storefront for your items, just like the OpenSea Creature example storefront in this tutorial.
引用 https://docs.opensea.io/docs/1-structuring-your-smart-contract
OpenSeaCreatures ERC721 contracts
About OpenSeaCreatures.
This is a very simple sample ERC721 for the purposes of demonstrating integration with the OpenSea marketplace. We include a script for minting the items.
Additionally, this contract whitelists the proxy accounts of OpenSea users so that they are automatically able to trade the ERC721 item on OpenSea (without having to pay gas for an additional approval). On OpenSea, each user has a “proxy” account that they control, and is ultimately called by the exchange contracts to trade their items. (Note that this addition does not mean that OpenSea itself has access to the items, simply that the users can list them more easily if they wish to do so)
引用 https://github.com/ProjectOpenSea/opensea-creatures
$ truffle deploy --network rinkeby
Using network 'rinkeby'.
Running migration: 1_initial_migrations.js
Deploying Migrations...
... 0xe301680767e2d01...hash
Migrations: 0x629598f...hash
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying Creature...
... 0xf540...hash
Creature: 0x40098d....コントラクトのアドレス
Saving artifacts...
GitHubのReadmeはこうなってるけど
Minting tokens.
After deploying to the Rinkeby network, there will be a contract on Rinkeby that will be viewable on Rinkeby Etherscan. For example, here is a recently deployed contract. You should set this contract address and the address of your Metamask account as environment variables when running the minting script:
export OWNER_ADDRESS=""
export CONTRACT_ADDRESS=""
export NETWORK="rinkeby"
node scripts/mint.js
HDWalletProviderを指定する際に、アドレスのインデックスを指定しようとmint.jsを編集してたら
GitHubのReadmeと指定するべき環境変数が違ったので注意。
OWNER_ADDRESSはmint.jsで読み込んでますが
CONTRACT_ADDRESSは読み込まれておらず
NFT(ERC721)とFACTORY(ガチャ)の分岐があるので
今回はNFT(ERC721)なので、FACTORY_CONTRACT_ADDRESSを指定します。
const HDWalletProvider = require("truffle-hdwallet-provider")
const web3 = require('web3')
const MNEMONIC = process.env.MNEMONIC
const INFURA_KEY = process.env.INFURA_KEY
const FACTORY_CONTRACT_ADDRESS = process.env.FACTORY_CONTRACT_ADDRESS
const NFT_CONTRACT_ADDRESS = process.env.NFT_CONTRACT_ADDRESS
const OWNER_ADDRESS = process.env.OWNER_ADDRESS
途中省略
async function main() {
const provider = new HDWalletProvider(MNEMONIC, `https://${NETWORK}.infura.io/${INFURA_KEY}` , 5 )
const web3Instance = new web3(
provider
)
if (NFT_CONTRACT_ADDRESS) {
const nftContract = new web3Instance.eth.Contract(NFT_ABI, NFT_CONTRACT_ADDRESS, { gasLimit: "1000000" })
// Creatures issued directly to the owner.
for (var i = 0; i < NUM_CREATURES; i++) {
const result = await nftContract.methods.mintTo(OWNER_ADDRESS).send({ from: OWNER_ADDRESS });
console.log("Minted creature. Transaction: " + result.transactionHash)
}
} else if (FACTORY_CONTRACT_ADDRESS) {
NETWORKはすでにデプロイ時に反映済みなので
NFT_CONTRACT_ADDRESS、OWNER_ADDRESSを指定して実行しました。
$ export NFT_CONTRACT_ADDRESS="0x4006....デプロイしたContractのアドレス"
$ export OWNER_ADDRESS="0x01234...オーナーとするアドレス"
$ node scripts/mint.js
Minted creature. Transaction: 0xc90108641fa6b7...TxHash
Minted creature. Transaction: 0x52a54629d83812...TxHash
Minted creature. Transaction: 0x876160fee54a33...TxHash
Minted creature. Transaction: 0x500a341ec082c0...TxHash
Minted creature. Transaction: 0xc02abbbe93f762...TxHash