Help with minting upgradable ERC20 token

Hi,

Thanks for OpenZeppelin, looks to be a powerful framework.

I am a relative newbie, but I have done through the documentation and the OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat tutorial.

I have started writing my own token based on ERC20 and hardhat:

//SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";

contract DickyCoinV01 is OwnableUpgradeable, ERC20PausableUpgradeable {

    function initialize(uint256 _releaseTime) public initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
        __ERC20_init_unchained("RichTestToken", "RTEST");
        __Pausable_init_unchained();
        __ERC20Pausable_init_unchained();
		
		_mint(owner(), 2000000 * 10 ** 18);
		
		//TODO: Add Vesting and allocations
    }
}

I literally just started but I have a few questions:

Question 1: I am about to write some vesting code to allocate a certain amount of tokens to the developer and also to some pre-sales. How do I go about this? Do I allocate this out of the pre-minted tokens or do I mint more?

Question 2: If I want future offerings, would I need to do an upgrade, e.g. create another contract? Not sure how this works.

Question 3: How does an exchange buy and sell the tokens? E.g. I understand the owner can call the transfer function, but requires owner privileges, how is this done?, or is there a way to have a ‘public’ pool of some sort?

Question 4: How do I (if it is at all possible) set the initial price of the token? and how does this increase and decrease?

Thanks in advance, apologies if these are simple questions, I am having difficulty finding up-to-date documentation.

Regards

Richard

Hi, welcome! :wave:

I think you can transfer tokens to developers directly, if there are not too many accounts. Or you can create an airdrop contract, just like Uniswap distribute UNI, this needs developers to claim by themselves.

And pre-sale? Do you mean the Crowdsale contract? If so, I think you can have a look at this documentation: https://docs.openzeppelin.com/contracts/2.x/crowdsales

If your original contract does have your new feature function, I think you have got to upgrade your contract, maybe you can have a look at this tutorial: OpenZeppelin Upgrades: Step by Step Tutorial for Hardhat

I think you mean the decentralized exchange, such as Uniswap, anyway, for any kind of exchange, there should be a exchange rate or just the price to swap token. For more details about Uniswap, you can have a look at this article: https://pintail.medium.com/uniswap-a-good-deal-for-liquidity-providers-104c0b6816f2

And for decentralized exchange, users call token.aprove and then exchange can call transferFrom to get token from user to swap.

Have a look at the article I shared above.