Last active
December 27, 2022 18:23
-
-
Save farzaa/483c04bd5929b92d6c4a194bd3c515a5 to your computer and use it in GitHub Desktop.
End of Section #1 Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const main = async () => { | |
const nftContractFactory = await hre.ethers.getContractFactory('MyEpicNFT'); | |
const nftContract = await nftContractFactory.deploy(); | |
await nftContract.deployed(); | |
console.log("Contract deployed to:", nftContract.address); | |
// Call the function. | |
let txn = await nftContract.makeAnEpicNFT() | |
// Wait for it to be mined. | |
await txn.wait() | |
console.log("Minted NFT #1") | |
txn = await nftContract.makeAnEpicNFT() | |
// Wait for it to be mined. | |
await txn.wait() | |
console.log("Minted NFT #2") | |
}; | |
const runMain = async () => { | |
try { | |
await main(); | |
process.exit(0); | |
} catch (error) { | |
console.log(error); | |
process.exit(1); | |
} | |
}; | |
runMain(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('@nomiclabs/hardhat-waffle'); | |
module.export = { | |
solidity: '0.8.0', | |
networks: { | |
rinkeby: { | |
url: 'YOUR ALCHEMY_API_URL', | |
accounts: ['YOUR_PRIVATE_RINKEBY_ACCOUNT_KEY'], | |
}, | |
}, | |
};` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.8.0; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "hardhat/console.sol"; | |
contract MyEpicNFT is ERC721URIStorage { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() ERC721 ("SquareNFT", "SQUARE") { | |
console.log("This is my NFT contract. Woah!"); | |
} | |
function makeAnEpicNFT() public { | |
uint256 newItemId = _tokenIds.current(); | |
_safeMint(msg.sender, newItemId); | |
_setTokenURI(newItemId, "https://jsonkeeper.com/b/RUUS"); | |
_tokenIds.increment(); | |
console.log("An NFT w/ ID %s has been minted to %s", newItemId, msg.sender); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const main = async () => { | |
const nftContractFactory = await hre.ethers.getContractFactory('MyEpicNFT'); | |
const nftContract = await nftContractFactory.deploy(); | |
await nftContract.deployed(); | |
console.log("Contract deployed to:", nftContract.address); | |
// Call the function. | |
let txn = await nftContract.makeAnEpicNFT() | |
// Wait for it to be mined. | |
await txn.wait() | |
txn = await nftContract.makeAnEpicNFT() | |
// Wait for it to be mined. | |
await txn.wait() | |
}; | |
const runMain = async () => { | |
try { | |
await main(); | |
process.exit(0); | |
} catch (error) { | |
console.log(error); | |
process.exit(1); | |
} | |
}; | |
runMain(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In hardhat.config.js > line 3 >
module.export = {
It should be
module.exports = {