-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial mints to owner #39
Comments
Hi @mpixelz You can mint via etherscan as soon as you deployed and verified your contract using the ‘Write Contract’ feature. Please be sure to use the owner wallet address when you mint them. |
Hi, |
Hi @mpixelz, /*
* DISCLAIMER: please test this code on a test network
* before deploying your final contract.
*
* Usage without proper testing is at your own risk.
*/
constructor(
string memory _tokenName,
string memory _tokenSymbol,
uint256 _cost,
uint256 _maxSupply,
uint256 _maxMintAmountPerTx,
string memory _hiddenMetadataUri
) ERC721(_tokenName, _tokenSymbol) {
cost = _cost;
maxSupply = _maxSupply;
maxMintAmountPerTx = _maxMintAmountPerTx;
setHiddenMetadataUri(_hiddenMetadataUri);
// Reserve initial tokens for giveaways and rewards...
_mintLoop(msg.sender, 10);
} |
@liarco makes a good point about testing. For any new features, it would be great to have a test added to this file: https://github.com/hashlips-lab/nft-erc721-collection/blob/main/smart-contract/test/index.ts I'm not too familiar with Javascript so hard for me to contribute example. @mpixelz If you look here at Cool Cats contract, they have a similar example in constructor with dedicated addresses: // withdraw addresses
address t1 = 0xfc86A64a8DE22CF25410F7601AcBd8d6630Da93D;
address t2 = 0x4265de963cdd60629d03FEE2cd3285e6d5ff6015;
address t3 = 0x1b33EBa79c4DD7243E5a3456fc497b930Db054b2;
address t4 = 0x92d79ccaCE3FC606845f3A66c9AeD75d8e5487A9;
// Cool Cats are so cool they dont need a lots of complicated code :)
// 9999 cats in total, cos cats have 9 lives
constructor(string memory baseURI) ERC721("Cool Cats", "COOL") {
setBaseURI(baseURI);
// team gets the first 4 cats
_safeMint( t1, 0);
_safeMint( t2, 1);
_safeMint( t3, 2);
_safeMint( t4, 3);
} |
Thank you for your suggestion, this is a diff file for the complete change: diff --git a/smart-contract/contracts/YourNftToken.sol b/smart-contract/contracts/YourNftToken.sol
index 2c77d74..e86b002 100644
--- a/smart-contract/contracts/YourNftToken.sol
+++ b/smart-contract/contracts/YourNftToken.sol
@@ -42,6 +42,9 @@ contract YourNftToken is ERC721, Ownable, ReentrancyGuard {
maxSupply = _maxSupply;
maxMintAmountPerTx = _maxMintAmountPerTx;
setHiddenMetadataUri(_hiddenMetadataUri);
+
+ // Reserve initial tokens for giveaways and rewards...
+ _mintLoop(msg.sender, 10);
}
modifier mintCompliance(uint256 _mintAmount) {
diff --git a/smart-contract/test/index.ts b/smart-contract/test/index.ts
index 739a382..8d17224 100644
--- a/smart-contract/test/index.ts
+++ b/smart-contract/test/index.ts
@@ -69,7 +69,9 @@ describe(CollectionConfig.contractName, function () {
expect(await contract.whitelistMintEnabled()).to.equal(false);
expect(await contract.revealed()).to.equal(false);
- await expect(contract.tokenURI(1)).to.be.revertedWith('ERC721Metadata: URI query for nonexistent token');
+ expect(await contract.tokenURI(1)).to.equal(CollectionConfig.hiddenMetadataUri);
+ expect(await contract.tokenURI(10)).to.equal(CollectionConfig.hiddenMetadataUri);
+ await expect(contract.tokenURI(11)).to.be.revertedWith('ERC721Metadata: URI query for nonexistent token');
});
it('Before any sale', async function () {
@@ -91,7 +93,7 @@ describe(CollectionConfig.contractName, function () {
)).to.be.revertedWith('Invalid mint amount!');
// Check balances
- expect(await contract.balanceOf(await owner.getAddress())).to.equal(1);
+ expect(await contract.balanceOf(await owner.getAddress())).to.equal(11);
expect(await contract.balanceOf(await whitelistedUser.getAddress())).to.equal(1);
expect(await contract.balanceOf(await holder.getAddress())).to.equal(0);
expect(await contract.balanceOf(await externalUser.getAddress())).to.equal(0);
@@ -154,7 +156,7 @@ describe(CollectionConfig.contractName, function () {
await contract.setCost(utils.parseEther(CollectionConfig.preSale.price.toString()));
// Check balances
- expect(await contract.balanceOf(await owner.getAddress())).to.equal(1);
+ expect(await contract.balanceOf(await owner.getAddress())).to.equal(11);
expect(await contract.balanceOf(await whitelistedUser.getAddress())).to.equal(2);
expect(await contract.balanceOf(await holder.getAddress())).to.equal(0);
expect(await contract.balanceOf(await externalUser.getAddress())).to.equal(0);
@@ -214,15 +216,25 @@ describe(CollectionConfig.contractName, function () {
it('Wallet of owner', async function () {
expect(await contract.walletOfOwner(await owner.getAddress())).deep.equal([
BigNumber.from(1),
- ]);
- expect(await contract.walletOfOwner(await whitelistedUser.getAddress())).deep.equal([
BigNumber.from(2),
BigNumber.from(3),
+ BigNumber.from(4),
+ BigNumber.from(5),
BigNumber.from(6),
+ BigNumber.from(7),
+ BigNumber.from(8),
+ BigNumber.from(9),
+ BigNumber.from(10),
+ BigNumber.from(11),
+ ]);
+ expect(await contract.walletOfOwner(await whitelistedUser.getAddress())).deep.equal([
+ BigNumber.from(12),
+ BigNumber.from(13),
+ BigNumber.from(16),
]);
expect(await contract.walletOfOwner(await holder.getAddress())).deep.equal([
- BigNumber.from(4),
- BigNumber.from(5),
+ BigNumber.from(14),
+ BigNumber.from(15),
]);
expect(await contract.walletOfOwner(await externalUser.getAddress())).deep.equal([]);
});
@@ -232,7 +244,7 @@ describe(CollectionConfig.contractName, function () {
this.skip();
}
- const alreadyMinted = 6;
+ const alreadyMinted = 16;
const maxMintAmountPerTx = 1000;
const iterations = Math.floor((CollectionConfig.maxSupply - alreadyMinted) / maxMintAmountPerTx);
const expectedTotalSupply = iterations * maxMintAmountPerTx + alreadyMinted;
You can replicate the changes manually or use the git-apply command to apply everything automatically. |
@liarco Thank you! Btw, I didn't mean for you to contribute the testing example. I was just trying to teach others that a test file exists and its good idea to update it when adding new features. Anyway, I guess this was easy for you to do. Sorry if too much time taken by my comment. |
Don't worry @spike-hue, all good! 😉 I did that because I thought it was a good idea to have an example, this may also be useful as future reference. |
Closing for inactivity. |
Hi |
Hi @mpixelz, that's because that specific code used version /*
* DISCLAIMER: please test this code on a test network
* before deploying your final contract.
*
* Usage without proper testing is at your own risk.
*/
constructor(
string memory _tokenName,
string memory _tokenSymbol,
uint256 _cost,
uint256 _maxSupply,
uint256 _maxMintAmountPerTx,
string memory _hiddenMetadataUri
) ERC721(_tokenName, _tokenSymbol) {
cost = _cost;
maxSupply = _maxSupply;
maxMintAmountPerTx = _maxMintAmountPerTx;
setHiddenMetadataUri(_hiddenMetadataUri);
// Reserve initial tokens for giveaways and rewards...
_safeMint(msg.sender, 10);
} Let me know if it works now... |
Will this work on the ERC721A new contract too? |
constructor( _safeMint(msg.sender, 10); when i set it like this it says the total of mints i have in my wallet is only one, im trying to mint 10 or more. Pls help |
Hi,
As previously.. i asked the same question but assuming things have changed with this new package. As there are new terminal commands and different loops in them..
how can i make it so that when the contract is deployed, initial 10 nfts are automatically minted to owner..
we are looking to secure the initial mints on deployment for 2 main reasons..
please let me know what would be the best way to accomplish it.
Thanks.
The text was updated successfully, but these errors were encountered: