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?
Asked
Active
Viewed 263 times
1
user938363
- 669
- 1
- 6
- 23
1 Answers
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).
clement
- 4,302
- 2
- 17
- 35
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 Dec 19 '20 at 23:56It 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_mintis called withaddress(this)for theaccountparameter. – clement Dec 21 '20 at 16:26