Hello, guys!
I'm starting into solidity development and I've a problem with a contract. I'm deploying the contract, and the 0x00 should send me the tokens to my address (and it appears like that in a tx), but it appears like 0 holders and the tokens are not sent to me.
I'm looking for into transfer and balances functions, but I don't find anything... Any idea? 😅
Oct 25, 2023, 3:41 AM
If you use ERC20 standard's default mint function:
constructor(uint256 numberTokensToMint) {
_mint(msg.sender, numberTokensToMint);
}
=================================
if you use direct change to balances variable:
event Transfer(address indexed from, address indexed to, uint256 value);
mapping(address => uint256) private _balances;
constructor(address account) {
_balances[account] = numberTokensToMint;
emit Transfer(address(0), account, numberTokensToMint);
}
==============================
Transfer event is used by token explorers to determine what amount of tokens and to which address they were sent. In that case it will appear from address(0) to account for numberTokensToMint. If you change the parameters on the Transfer event, you can make it appear whatever you like.
constructor(uint256 numberTokensToMint) {
_mint(msg.sender, numberTokensToMint);
}
=================================
if you use direct change to balances variable:
event Transfer(address indexed from, address indexed to, uint256 value);
mapping(address => uint256) private _balances;
constructor(address account) {
_balances[account] = numberTokensToMint;
emit Transfer(address(0), account, numberTokensToMint);
}
==============================
Transfer event is used by token explorers to determine what amount of tokens and to which address they were sent. In that case it will appear from address(0) to account for numberTokensToMint. If you change the parameters on the Transfer event, you can make it appear whatever you like.
Oct 26, 2023, 7:10 AM
Okay, I'll try. Thanks!
Oct 26, 2023, 11:14 PM