Skip to content
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

Customizing contracts - Mint Tokens on Deployment #7

Open
AddressXception opened this issue Apr 20, 2022 · 0 comments
Open

Customizing contracts - Mint Tokens on Deployment #7

AddressXception opened this issue Apr 20, 2022 · 0 comments

Comments

@AddressXception
Copy link
Member

As a developer I would like to mint 100 tokens to a designated address when my contract is deployed so that the owner of the address can view the minted tokens in their wallet.

Our contract must mint 100 tokens to a specific wallet when it is deployed. Add an internal function that will call the _safeMint function found in the ERC721.sol base contract. The function should accept an address as a parameter. Call the function from the contract constructor.

Our contract will automatically mint 100 NFT's to a designated wallet when the contract is deployed. This is a common pattern for handling custom 1 of 1 artwork, or when allocating a portion of the tokens internally to the team, etc. Our contract will also allow up to 900 total tokens to be minted publicly but we will worry about that in the next section.

Since we want to mint our tokens on contract deployment, we require an internal function. Function visibility in solidity works similarly to other languages with one major caveat:

there's no such thing as private data on the blockchain.

since nodes on the network must be able to deterministically resolve a function, all private variables and access is simply not added to the public interfaces, but it is viewable on any node.

Check out this excellent post on access in solidity

For our function, we need to accept a single address as a parameter and create a simple loop that mints 100 tokens using the _safeMint function.

john-s-morgan added a commit that referenced this issue May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant