0

I have an ERC20 token with a mint function that looks like this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyContract is ERC20 {

    constructor() public payable ERC20("MyContract", "MYCT") {}

    function mintOverride() public payable {
        address payable addressOne = payable(0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2); // Fake address
        address payable addressTwo = payable(0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db); // Fake address
        require(msg.value >= 0.05 ether, "Not enough ETH sent; check price!");   
        _mint(msg.sender, 1);
    }
}

But rather than have 100% precent of the Eth received going to a the contract issuer, I want to send some to addresses addressOne and addressTwo and potentially others

1 Answer 1

0

You're over thinking it, either mint then distribute or mint directly to each wallet.

constructor(uint256 amount1, uint256 amount2, uint256 total) ERC20("MyContract", "MYCT") {
    address addressOne = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
    address addressTwo = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
    _mint(owner(), total - amount1 - amount2);
    _mint(addressOne, amount1);
    _mint(addressTwo, amount2);
}

Or

constructor(uint256 amount1, uint256 amount2, uint256 total) ERC20("MyContract", "MYCT") {
    address addressOne = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
    address addressTwo = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
    _mint(address(this), total);
    this.transfer(addressOne, amount1);
    this.transfer(addressTwo, amount2);
    this.transfer(owner(), balanceOf(address(this))))
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.