-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
939fc06
commit 17a056b
Showing
6 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
.../build/isc/v1.0.0-rc.6/docs/_partials/how-tos/token/_obsolete_token_creation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:::caution | ||
|
||
This method is now obsolete, use the new [`createNativeTokenFoundry`](../../../how-tos/core-contracts/token/create-native-token.md) method instead. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
.../build/isc/v1.0.0-rc.6/docs/how-tos/core-contracts/token/create-native-token.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
--- | ||
description: How to Create a Native Token Foundary. | ||
image: /img/logo/WASP_logo_dark.png | ||
tags: | ||
- foundry | ||
- EVM | ||
- how-to | ||
- native tokens | ||
- mint | ||
- register | ||
--- | ||
|
||
import ExampleCodeIntro from '../../../_partials/how-tos/token/_example_code_intro.md'; | ||
|
||
# Create a Native Token | ||
|
||
This guide will show you how you can efficiently mint new tokens and register them for use as ERC20 tokens with the `createNativeTokenFoundry` function in one seamless operation. It will create a foundry on L1 and register it as an ERC20 on L2. This method ensures that only the foundry owner can mint tokens, maintaining security and control over the token creation process. | ||
|
||
## About Foundries | ||
|
||
The Stardust update allows you to create your own native tokens. Native tokens are minted by a [Foundry](/tips/tips/TIP-0018/#foundry-output). | ||
The Foundry lets you specify your native token's maximum supply **once** and change the circulating supply. | ||
|
||
## Example Code | ||
|
||
<ExampleCodeIntro/> | ||
|
||
### 2. Define the Token Scheme | ||
|
||
Define the `NativeTokenScheme` by specifying its `mintedTokens`, `meltedTokens`, and `maximumSupply`. For simplicity, in this guide we mint the whole maximum supply at creation. | ||
|
||
```solidity | ||
NativeTokenScheme memory nativeTokenScheme = NativeTokenScheme({ | ||
mintedTokens: _maximumSupply, | ||
meltedTokens: 0, | ||
maximumSupply: _maximumSupply | ||
}); | ||
``` | ||
|
||
### 3. Mint and Register Native Token | ||
|
||
Minting native tokens and registering them as ERC20 tokens using `createNativeTokenFoundry` method | ||
|
||
```solidity | ||
uint32 foundrySN = ISC.accounts.createNativeTokenFoundry( | ||
_tokenName, | ||
_tokenSymbol, | ||
_tokenDecimals, | ||
nativeTokenScheme, | ||
allowance | ||
); | ||
``` | ||
|
||
## Full Example Code | ||
|
||
```solidity | ||
pragma solidity ^0.8.0; | ||
import "@iota/iscmagic/ISC.sol"; | ||
contract MyToken { | ||
event MintedToken(uint32 foundrySN); | ||
constructor( | ||
string memory _tokenName, | ||
string memory _tokenSymbol, | ||
uint8 _tokenDecimals, | ||
uint256 _maximumSupply, | ||
uint64 _storageDeposit | ||
) payable { | ||
require(msg.value == _storageDeposit * (10**12), "Please send exact funds to pay for storage deposit"); | ||
ISCAssets memory allowance; | ||
allowance.baseTokens = _storageDeposit; | ||
NativeTokenScheme memory nativeTokenScheme = NativeTokenScheme({ | ||
mintedTokens: _maximumSupply, | ||
meltedTokens: 0, | ||
maximumSupply: _maximumSupply | ||
}); | ||
uint32 foundrySN = ISC.accounts.createNativeTokenFoundry( | ||
_tokenName, | ||
_tokenSymbol, | ||
_tokenDecimals, | ||
nativeTokenScheme, | ||
allowance | ||
); | ||
emit MintedToken(foundrySN); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters