This contract has been received and approved by the Coinbase Blockchain Security team. However, Coinbase is not liable for any outcomes as a result of using this starter kit. Please DYOR before launching your project using this NFT contract.
NonFungibleCoinbae
(deployed to Rinkeby Testnet): 0xCa4E3b3f98cCA9e801f88F13d1BfE68176a03dFA
Before you start, make sure you have the following available:
- Have access to the public (public wallet address) and private key to your Ethereum account
- Set up an Alchemy (Recommended) or Infura account (the free one works!) to retrieve an API endpoint
- Set up an etherscan account and obtain the API key (optional)
- If deploying on testnet, fill up your test wallet with some test ETH: Paradigm, Alchemy, Chainlink faucets (optional)
-
Install dependencies
yarn install
-
Make a copy of
.env.sample
as.env
and fill in detailscp .env.sample .env
Please note the required fields. The
CONTRACT_ADDRESS
field should only be filled out after you deploy the smart contract. -
Make your modifications to the smart contract in
./contract/nft.sol
-
Compile the contract
npx hardhat compile
-
Deploy the contract (default network is set to Rinkeby)
yarn deploy
To customize the network (to local or test networks)
npx hardhat run scripts/deploy.js --network [network of choice]
We recommend you deploy to a local network or testnet such as Rinkeby to start.
If needed, modify
scripts/deploy.js
to include the specific deploy arguments that you want your ERC721 contract to be deployed with. Make sure the parameter passed intoawait hre.ethers.getContractFactory
matches the name of the compiled smart contract exactly. -
Verify the contract on Etherscan (optional, default network is set to Rinkeby)
Update
CONTRACT_ADDRESS
with the deployed contract address and run the following script to verify your contract on Etherscanyarn verify
To customize the network (make sure network is supported by Etherscan)
npx hardhat etherscan-verify --network [network of choice]
Run yarn test
. Additionally, this repository has been configured with a Github workflow (see hardhat-tests.yml
) to run the smart contract tests on every pull request.
There are some contract interaction scripts and npm commands to make interacting with our smart contracts more convenient. Make sure to update these scripts as you modify the contract.
Scripts for contract interactions and generate merkle roots are located in scripts
.
Try running some of the following tasks:
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
npx hardhat help
To allowlist addresses for a presale, update the list of addresses in smart-contracts/allowlists/presaleList.json
(do NOT edit the file of the same name on the frontend) and run the following script:
yarn task:setPresaleListMerkle
To modify the active sale states, run the following scripts:
yarn task:setPublicSaleActive
yarn task:setPresaleActive
yarn task:setSaleInactive
To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Rinkeby.
In this project, copy the .env.sample file to a file named .env, and then edit it to fill in the details. Enter your Etherscan API key, your Rinkeby node URL (eg from Alchemy), and the private key of the account which will send the deployment transaction. With a valid .env file in place, first deploy your contract:
hardhat run --network rinkeby scripts/deploy.js
Then, copy the deployment address and paste it in to replace DEPLOYED_CONTRACT_ADDRESS
in this command:
npx hardhat verify --network rinkeby DEPLOYED_CONTRACT_ADDRESS [deploy parameters]
Alternatively, we've created a command to make this process faster on Rinkeby testnet. Run npm run rinkeby:verify DEPLOYED_CONTRACT_ADDRESS [deploy parameters]
to verify your contract deployed on Rinkeby.
Method | Gas | Average Cost (@ Gas Price of 50 gwei) |
---|---|---|
Contract Deploy | 4,747,369 | 0.23736845 ETH |
Set is Public/Presale Active | 29,063 | 0.00145315 ETH |
Set Base URI | 115,025 | 0.00575125 ETH |
Set Merkle Root | 29,085 | 0.00145425 ETH |
Public Mint (1 NFT) | 65,630 | 0.0032815 ETH |
Public Mint (3 NFTs) | 152,074 | 0.0076037 ETH |
- We recommend you use a burner wallet for all testing. Please be careful with your private keys and make sure you only put them in the
.env
files. Hardcoding them anywere or including them in a file that is not in the.gitignore
can lead to your private keys being comprimised. - You can use any RPC provider of your choice but we've had the best experience using Alchemy or Infura.
- An Etherscan API key is required for contract verification.
Please note that the owner of the deployed NFT contract will have the ability to perform the following sensitive operations at any time:
- Withdraw funds from the contract
- Reserve tokens and gift tokens to others
- Activate and deactivate the sale states
- Set and update the royalty address
- Set and update the metadata URI
- Set and update the allowlist
We recommend project team to transfer the ownership of the contract to a multi-sig wallet (Gnosis Safe recommended) to reduce the risks that come with a single superuser account. As the contract is an Ownable, you can use the transferOwnership function to do so.
We also advise project teams to make users in their community aware of these superuser contract methods.
Please note that frontrunning protection from individuals with MEV-based solutions are not present in this contract.