Skip to main content

Command Palette

Search for a command to run...

Smart contract pattern

Published
1 min readView as Markdown

Now let us say there is a smart contract A that is minting lets say 1000 tokens in its constructor by inheriting the ERC20 smart contract. Also there is a smart contract B that wants to have those 1000 tokens that are minted by the smart contract A. However when deploying the smart contract A as we don't yet know the address of the smart contract B we cannot send it inside its constructor and hence B will not get 1000 tokens.

The solution for this is that deploy the smart contract A by passing the address of the deployer and hence the deployer account address will get 1000 tokens. Now deploy the smart contract B. Now inside the deployment script transfer the tokens from the deployer address to the smart contract B using the transfer function.

Hence now the tokens are present in the smart contract B

More from this blog

Dhruv's Web development journey

64 posts