Skip to content

Commit

Permalink
Register token
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Feb 20, 2024
1 parent 935673c commit ab23378
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 29 deletions.
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;
```
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/>
16 changes: 2 additions & 14 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/token/create-foundry.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ tags:
- EVM
- how-to
---

import Ownership from '../../_admonitions/_ownership.md';
import Payable from '../../_admonitions/_payable.md';
import ExampleCodeIntro from '../../_partials/how-tos/token/_example_code_intro.md';

# Create a Foundry
## About Foundries
Expand All @@ -19,17 +17,7 @@ This guide will show you how to create an L1 foundry using a L2 smart contract.

## Example Code

<Ownership/>

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;
```

<Payable/>
<ExampleCodeIntro/>

2. Define the `NativeTokenScheme`:

Expand Down
17 changes: 2 additions & 15 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/token/mint-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ tags:
- native tokens
- mint
---

import Ownership from '../../_admonitions/_ownership.md';
import Payable from '../../_admonitions/_payable.md';
import ExampleCodeIntro from '../../_partials/how-tos/token/_example_code_intro.md';

# Mint Native Tokens

Expand All @@ -19,18 +17,7 @@ so you should execute the `ISC.accounts.mintNativeTokens` function in the same c

## Example Code

<Ownership/>

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;
```

<Payable/>
<ExampleCodeIntro/>

2. Mint the native token specifying the foundry serial number, the amount to mint and the allowance.

Expand Down
48 changes: 48 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/token/register-token.md
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);
}
```
5 changes: 5 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ module.exports = {
label: 'Mint a Native Token',
id: 'how-tos/token/mint-token',
},
{
type: 'doc',
label: 'Register Token as ERC20',
id: 'how-tos/token/register-token',
},
],
},
],
Expand Down

0 comments on commit ab23378

Please sign in to comment.