Adapted for hardhat from https://github.com/ProjectOpenSea/opensea-creatures. Uses Arweave to store contract and image metadata.
Contract Features: Mintable with Auto Increment Ids, Burnable, Enumerable, URI Storage
Access Control: Ownable
Whitelists OpenSea's trading address
git clone https://github.com/dynamiculture/erc721-opensea-hardhat-template
cd erc721-opensea-hardhat-template
npm i
# list hardhat tasks:
npx hardhat
npm i -g hardhat-shorthand
hardhat-completion install
# hh == npx hardhat
Create free accounts on:
Create .env (listed in .gitignore). Important! Do not check in .env to public repo:
cp .env.sample .env
enter the following values into .env:
- INFURA_API_KEY=
- ETHERSCAN_API_KEY=
Clean, compile and test:
hh clean
TS_NODE_TRANSPILE_ONLY=1 hh compile
hh compile
hh test
hh coverage
hh node
In a new terminal, go to the repository's root folder and run this to deploy your contract:
hh deploy --network localhost
update LOCALHOST_CONTRACT_ADDRESS .env with address of newly deployed contract.
hh mint-token --network localhost --metadata-uri ar://8_NZWr4K9d6N8k4TDbMzLAkW6cNQnSQMLeoShc8komM
npx arweave key-save <json file>
npx arweave deploy assets/qxs.jpg
After Arweave deployment, update value for "image" with the resulting Arweave URL in qxs-contract.json. Deploy qxs-contract.json:
npx arweave deploy data/qxs-contract.json
Update "contractURI" in contracts/QXS.sol
Upload image as a 480x480 animated gif:
ffmpeg -i qxs-1.mp4 -vf scale=480:-1 qxs-1.gif
npx arweave deploy assets/qxs-1.gif
After Arweave deployment, update "image" with the resulting Arweave URL (ar://) in qxs-1.json.
Upload animation_url as a 1024x1024 mp4 with vcodec H.264, pixel format YUV 4:2:0, and CRF 25. Arweave image or video should be less than 10MB:
npx arweave deploy assets/qxs-1.mp4
After Arweave deployment, update "animation_url" with the resulting Arweave URL (ar://) in qxs-1.json. Deploy qxs-1.json:
npx arweave deploy data/qxs-1.json
Note new Arweave path (ar://) to token metadata file for minting
Get ether on Rinkeby: https://faucet.rinkeby.io/
Supply the private key of the contract owner in .env:
- RINKEBY_PRIVATE_KEY=
Deploy contract to Rinkeby:
hh deploy --network rinkeby
Note the deployed contract's address and update value in .env:
- RINKEBY_CONTRACT_ADDRESS=
Run the following command, by providing the new contract address. The last value is a constructor argument, OpenSea's proxy address on Rinkeby:
hh verify --network rinkeby --contract contracts/QXS.sol:QXS <contract-address> 0xf57b2c51ded3a29e6891aba85459d600256cf317
Visit the following URL, by providing the new contract address: https://rinkeby.etherscan.io/address/_contract-address_
hh mint-token --network rinkeby --metadata-uri ar://8_NZWr4K9d6N8k4TDbMzLAkW6cNQnSQMLeoShc8komM
Go to https://testnets.opensea.io/ connect wallet using the Rinkeby network. Choose "My Collections" and "Import an existing smart contract". Enter the Rinkeby Contract Address.
hh burn-token --network rinkeby --token-id 22
Token will be transferred to the zero address and marked as nonexistent token
hh deploy --network mainnet
note the depoloyed contract's address and update value in .env:
- MAINNET_CONTRACT_ADDRESS=
Run the following command, by providing the new contract address. The last value is a constructor argument, OpenSea's proxy address on mainnet:
hh verify --network mainnet --contract contracts/QXS.sol:QXS <contract-address> 0xa5409ec958c83c3f309868babaca7c86dcb077c1
Visit the following URL, by providing the new contract address: https://etherscan.io/address/_contract-address__#code
hh mint-token --network mainnet --metadata-uri ar://8_NZWr4K9d6N8k4TDbMzLAkW6cNQnSQMLeoShc8komM
hh burn-token --network mainnet --token-id 22
Token will be transferred to the zero address and marked as nonexistent token
Go to https://opensea.io/ and connect wallet using the mainnet network. Choose "My Collections" and "Import an existing smart contract". Enter the mainnet Contract Address.