Skip to content

Instantly share code, notes, and snippets.

@rounakbanik
Created October 31, 2021 18:31
Show Gist options
  • Save rounakbanik/006f92aaef07af136578eda1697d878c to your computer and use it in GitHub Desktop.
Save rounakbanik/006f92aaef07af136578eda1697d878c to your computer and use it in GitHub Desktop.
const { utils } = require("ethers");
async function main() {
const baseTokenURI = "ipfs://QmZbWNKJPAjxXuNFSEaksCJVd1M6DaKQViJBYPK2BdpDEP/";
// Get owner/deployer's wallet address
const [owner] = await hre.ethers.getSigners();
// Get contract that we want to deploy
const contractFactory = await hre.ethers.getContractFactory("NFTCollectible");
// Deploy contract with the correct constructor arguments
const contract = await contractFactory.deploy(baseTokenURI);
// Wait for this transaction to be mined
await contract.deployed();
// Get contract address
console.log("Contract deployed to:", contract.address);
// Reserve NFTs
let txn = await contract.reserveNFTs();
await txn.wait();
console.log("10 NFTs have been reserved");
// Mint 3 NFTs by sending 0.03 ether
txn = await contract.mintNFTs(3, { value: utils.parseEther('0.03') });
await txn.wait()
// Get all token IDs of the owner
let tokens = await contract.tokensOfOwner(owner.address)
console.log("Owner has tokens: ", tokens);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment