-
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
935673c
commit ab23378
Showing
6 changed files
with
74 additions
and
29 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
docs/build/isc/v1.0.0-rc.6/docs/_partials/how-tos/token/_check_storage_deposit.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,8 @@ | ||
1. Check if the amount paid to the contract is the same as the required [storage deposit](/learn/protocols/stardust/core-concepts/storage-deposit) | ||
and set the allowance. | ||
|
||
```solidity | ||
require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); | ||
ISCAssets memory allowance; | ||
allowance.baseTokens = _storageDeposit; | ||
``` |
9 changes: 9 additions & 0 deletions
9
docs/build/isc/v1.0.0-rc.6/docs/_partials/how-tos/token/_example_code_intro.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,9 @@ | ||
import Ownership from '../../../_admonitions/_ownership.md'; | ||
import Payable from '../../../_admonitions/_payable.md'; | ||
import CheckStorageDeposit from './_check_storage_deposit.md' | ||
|
||
<Ownership/> | ||
|
||
<CheckStorageDeposit/> | ||
|
||
<Payable/> |
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
48 changes: 48 additions & 0 deletions
48
docs/build/isc/v1.0.0-rc.6/docs/how-tos/token/register-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,48 @@ | ||
--- | ||
description: How to register a native token as ERC20 | ||
image: /img/logo/WASP_logo_dark.png | ||
tags: | ||
- ERC20 | ||
- EVM | ||
- how-to | ||
--- | ||
import ExampleCodeIntro from '../../_partials/how-tos/token/_example_code_intro.md'; | ||
|
||
# Register Tokens | ||
|
||
To properly use your native tokens, you should register them as ERC20 using the `registerERC20NativeToken` function from the ISC magic contract. | ||
|
||
## Example Code | ||
|
||
<ExampleCodeIntro/> | ||
|
||
|
||
2. Register the native tokens specifying: | ||
* the foundry serial number | ||
* a name | ||
* a symbol | ||
* it's decimals | ||
* the allowance. | ||
```solidity | ||
ISC.sandbox.registerERC20NativeToken(_foundrySN, _name, _symbol, _decimals, allowance); | ||
``` | ||
|
||
3. Get the ERC20 contract address with `erc20NativeTokensAddress`: | ||
```solidity | ||
address erc20address = ISC.sandbox.erc20NativeTokensAddress(_foundrySN); | ||
``` | ||
|
||
### Full Example Code | ||
|
||
```solidity | ||
event ERC20Address(address erc20address); | ||
function registerERC20NativeToken(uint32 _foundrySN, string calldata _name, string calldata _symbol, uint8 _decimals, uint64 _storageDeposit) public payable { | ||
require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); | ||
ISCAssets memory allowance; | ||
allowance.baseTokens = _storageDeposit; | ||
ISC.sandbox.registerERC20NativeToken(_foundrySN, _name, _symbol, _decimals, allowance); | ||
address erc20address = ISC.sandbox.erc20NativeTokensAddress(_foundrySN); | ||
emit ERC20Address(erc20address); | ||
} | ||
``` |
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