0

im creating an ERC20 token and i want to specify a maximium supply for my token?

I want to mint 2000 tokens.

1000 of that tokens to my wallet, and leave in the contract the other 1000 tokens.

Is that possibly?

1 Answer 1

0

You can achieve this with OpenZeppelin using the following code:

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

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

contract ERC20FixedSupply is ERC20 {
    constructor() ERC20("Fixed", "FIX") {
        _mint(msg.sender, 1000); // Mints 1000 tokens to your wallet
        _mint(address(this), 1000); // Mints 1000 tokens to the contract
    }
}

There's some more info in the docs here!

1
  • 2
    This is more like a total supply, not a max supply.
    – Peter
    Commented Feb 21, 2022 at 6:20

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.