Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mint token #1468

Merged
merged 26 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6748f63
Add 'Create Foundry' how-to
Dr-Electron Feb 11, 2024
b165346
Remove ethersjs
Dr-Electron Feb 16, 2024
1d1cfdb
Update how-to
Dr-Electron Feb 16, 2024
e035aac
Mint native token
Dr-Electron Feb 16, 2024
8ffaf54
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
a723c7e
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
820a117
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
fb882fb
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
9f84a83
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
7edf206
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
Dr-Electron Feb 19, 2024
9c74765
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/native-token/mint-toke…
Dr-Electron Feb 19, 2024
d59e169
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/native-token/mint-toke…
Dr-Electron Feb 19, 2024
9665412
Update docs/build/isc/v1.0.0-rc.6/docs/how-tos/native-token/mint-toke…
Dr-Electron Feb 19, 2024
5b57b70
Update contract and add admonitions
Dr-Electron Feb 20, 2024
a12e03d
Merge branch 'createFoundry' into mint-token
Dr-Electron Feb 20, 2024
84cfb64
Rename section
Dr-Electron Feb 20, 2024
a9ea8af
Update units
Dr-Electron Feb 20, 2024
52834c7
Merge branch 'createFoundry' into mint-token
Dr-Electron Feb 20, 2024
ec64dfe
Update contract and docs
Dr-Electron Feb 20, 2024
d202a3e
Added format suggestions
lucas-tortora Feb 20, 2024
f2a4018
Merge branch 'createFoundry' into mint-token
Dr-Electron Feb 20, 2024
12cd0ee
Export admonitions
Dr-Electron Feb 20, 2024
a68e447
Remove spaces
Dr-Electron Feb 20, 2024
eadffef
Add example line
Dr-Electron Feb 20, 2024
ebda334
rephrase intro and first step
lucas-tortora Feb 20, 2024
207d883
Merge branch 'ISC/restructure' into mint-token
Dr-Electron Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
description: How to create a L1 foundry
image: /img/logo/WASP_logo_dark.png
tags:
- foundry
- EVM
- how-to
---

## About Foundry

The stardust update allows you to create your own native tokens. Native tokens are minted by a so-called Foundry. The Foundry allows you to specify a max supply once and change the circulating supply. This how-to will explain how to create a L1 foundry from L2.

## Example Code

1. Define the `NativeTokenScheme`

```solidity
NativeTokenScheme memory nativeTokenScheme = NativeTokenScheme({
mintedTokens: _mintedTokens,
meltedTokens: _meltedTokens,
maximumSupply: _maximumSupply
});
```

2. Set the allowance

```
ISCAssets memory allowance = ISCAssets({
baseTokens: 500_000,
nativeTokens: new NativeToken[](0),
nfts: new NFTID[](0)
});
```

3. Create the foundry

```solidity
uint foundrySN = ISC.accounts.foundryCreateNew(nativeTokenScheme, allowance);
```

### Full Example Code

```solidity
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";

contract CreateFoundry {
event CreatedFoundry(uint foundrySN);

function createFoundry(uint _mintedTokens, uint _meltedTokens, uint _maximumSupply) public payable {
NativeTokenScheme memory nativeTokenScheme = NativeTokenScheme({
mintedTokens: _mintedTokens,
meltedTokens: _meltedTokens,
maximumSupply: _maximumSupply
});
ISCAssets memory allowance = ISCAssets({
baseTokens: 500_000,
nativeTokens: new NativeToken[](0),
nfts: new NFTID[](0)
});
uint foundrySN = ISC.accounts.foundryCreateNew(nativeTokenScheme, allowance);
emit CreatedFoundry(foundrySN);
}
}
```
34 changes: 34 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/native-token/mint-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: How to create a L1 foundry
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved
image: /img/logo/WASP_logo_dark.png
tags:
- foundry
- EVM
- how-to
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved
---


import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Minting Tokens
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

To mint tokens from a foundry, you first need to be aware that only the foundry owner can mint token so you might execute that function
in the same contract as [creating](./create-foundry.md) the foundry. You can then call the `ISC.accounts.mintNativeTokens` function.

## Example Code

1. Create the allowance
2. Mint the native token specifying the foundry serial number, the amount to mint and the allowance.
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

```solidity
function mintNativeTokens(uint32 _foundrySN, uint _amount) public payable{
ISCAssets memory allowance = ISCAssets({
baseTokens: 500_000,
nativeTokens: new NativeToken[](0),
nfts: new NFTID[](0)
});
ISC.accounts.mintNativeTokens(_foundrySN, _amount, allowance);
emit MintedNativeTokens(_foundrySN, _amount);
}
```
16 changes: 16 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 @@ -156,6 +156,22 @@ module.exports = {
label: 'Send Tokens to L1',
id: 'how-tos/send-tokens-to-l1',
},
{
type: 'category',
label: 'Core Contracts',
items: [
{
type: 'doc',
label: 'Create Foundry',
id: 'how-tos/native-token/create-foundry',
},
{
type: 'doc',
label: 'Mint Token',
id: 'how-tos/native-token/mint-token',
}
]
},
],
},
],
Expand Down
Loading