1

When an ERC20 smart contract (for example, @openZeppelin ERC20 contract) is deployed to ethereum network, there will be a deployedAddress of contract returned. Meanwhile the token is minted after deployment with a coinbaseAddress. Are the deployedAddress of the contract and coinbaseAddress of token the same?

1 Answer 1

1

The OpenZeppelin ERC20 implementation defines the mint function as follow :

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
 * the total supply.
 *
 * Emits a {Transfer} event with `from` set to the zero address.
 *
 * Requirements:
 *
 * - `to` cannot be the zero address.
 */
function _mint(address account, uint256 amount) internal virtual {
    require(account != address(0), "ERC20: mint to the zero address");

    _beforeTokenTransfer(address(0), account, amount);

    _totalSupply = _totalSupply.add(amount);
    _balances[account] = _balances[account].add(amount);
    emit Transfer(address(0), account, amount);
}

When called, this method sets _totalSupply and the address account receives the minted amount. account can be any address except the zero address. The Transfer event mentions the zero address as the from parameter but this is purely conventional.

There is no such thing of coinbaseAddress(What is coinbase?). The new coins are programmatically created by the smart contract.

Note that you can implement more complex supply mechanisms (see here for more info : https://docs.openzeppelin.com/contracts/3.x/erc20-supply).

3
  • The coinbase address is the address which receives all initial token supply in the post. This may not be the right way to use coinbase. It seems that the ERC20 contract deployment address and the address which receives all coin supply are not the same. BTW the link is for previous version of 2.x. Thanks for the reply.
    – user938363
    Commented Dec 19, 2020 at 23:56
  • It seems that the ERC20 contract deployment address and the address which receives all coin supply are not the same : The address receiving the supply can be any address, except the zero address. It could possibly be the ERC20 contract address if _mint is called with address(this) for the account parameter.
    – clement
    Commented Dec 21, 2020 at 16:26
  • Thanks, I updated the link to match version 3.x.
    – clement
    Commented Dec 21, 2020 at 16:39

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.