You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current code is probably correct. But this suggestion is to separate concerns for security reasons and code coverage during testing. The context of minting tokens during a ERC20 constructor is different from minting tokens a second time (without going through the constructor).
Example for security concern: We found out that, ICS20 contract can burn tokens from a user wallet without user approval -- but it did require an approval when we separated that process into transfer-to-self and then burn-from-self (#296 (comment)).
Example for better code coverage: When we transfer tokens from Osmosis to Starknet for the first time, it uses syscall to deploy a new contract
rnbguy
changed the title
create, mint, burn should have separate steps
create, mint, burn, transfer erc20 tokens should have separate scopes
Feb 20, 2025
We should create, mint, burn, transfer an ERC20 token in separate steps. There shouldn't be any overlap between them in the ERC20 contract.
create
should only happen with zero supply. This is mainly to set up the token metadata and initialize ownerships.mint
/burn
should only happen to/from ICS20 contract. It shouldn't mint/burn to/from a non-ICS20 contract or account.transfer
should only happen between ICS20 contract and another non-ICS20 contract.For example, the following
mint_execute
method has acreate_token(name, amount)
-- which calls the token constructor with non-zero initial supply.ibc-starknet/cairo-contracts/packages/apps/src/transfer/components/transfer.cairo
Lines 671 to 688 in 1414bc8
This should be separated by a constructor call with zero supply and a consecutive non-zero mint. So it should look something similar to this,
The current code is probably correct. But this suggestion is to separate concerns for security reasons and code coverage during testing. The context of minting tokens during a ERC20 constructor is different from minting tokens a second time (without going through the constructor).
Example for security concern: We found out that, ICS20 contract can burn tokens from a user wallet without user approval -- but it did require an approval when we separated that process into transfer-to-self and then burn-from-self (#296 (comment)).
Example for better code coverage: When we transfer tokens from Osmosis to Starknet for the first time, it uses syscall to deploy a new contract
ibc-starknet/cairo-contracts/packages/apps/src/transfer/erc20_call.cairo
Lines 51 to 54 in 1414bc8
We have to perform another transfer of the same token to use the
permissioned_mint
.ibc-starknet/cairo-contracts/packages/apps/src/transfer/erc20_call.cairo
Lines 69 to 71 in 1414bc8
The text was updated successfully, but these errors were encountered: