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

Add 'Create Foundry' how-to #1461

Merged
merged 13 commits into from
Feb 20, 2024
Merged
69 changes: 69 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/create-foundry.md
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
---

Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved
## About Foundry
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

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.
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

## Example Code

1. Define the `NativeTokenScheme`
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

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

2. Set the allowance
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

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

3. Create the foundry
Dr-Electron marked this conversation as resolved.
Show resolved Hide resolved

```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);
}
}
```
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 @@ -156,6 +156,11 @@ module.exports = {
label: 'Send Tokens to L1',
id: 'how-tos/send-tokens-to-l1',
},
{
type: 'doc',
label: 'Create Foundry',
id: 'how-tos/create-foundry',
}
],
},
],
Expand Down
Loading