Mint to uint256 address which is updateable from function

I would like to mint an amount to a specific but updateable wallet, so.....

Why can I not do this:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

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

import "@openzeppelin/contracts@4.6.0/access/Ownable.sol";

contract MyToken is ERC20, Ownable {

uint256 public extra;

function setextra(uint256 _extra) public onlyOwner {

        extra = _extra;

        return;

    }

    constructor() ERC20("MyToken", "MTK") {}

    function mint(address to, uint256 amount) public onlyOwner {

        _mint(to, amount);

        _mint(extra, 100);

    }

}

The first argument to _mint() needs to be an address, not uint256.

You can:
a) change the type of extra and _extra to address
OR
b) convert extra to an address: address(uint160(extra))

1 Like

Thank you, this is not the function in which I can change the address, and this works!!!!

function mint(address to, uint256 amount) public onlyOwner {
    _mint(to, amount);
    _mint(address(uint160(extra)), 100);