Is it possible to mint ERC20 tokens that are created in a parent contract, from a child contract? If so how is it implemented?
Thank you in advance!
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityIt's about access control and an appropriate function to call.
In the parent contract, you will need a mint or issueTokens()
function (to avoid name conflict/confusion).
function issueTokens(who, quantity) external onlyChildren ... { ... }
Notice the onlyChildren
modifier. That would control access so only trusted contracts are allowed to call the function.
Something like ...
modifier onlyChildren {
require( isChild[msg.sender], "don't know you" );
_;
}
Relies on a mapping that knows which contracts to trust.
mapping(address => bool) public isChild;
That relies on keeping track of deployed contracts:
Child child = new Child();
isChild[address(child)] = true;
Hope it helps.
msg.sender
in the constructor
context. So, roughly ParentInterface(myParent).doSomething()
Aug 17, 2021 at 0:00