Skip to content

Commit

Permalink
Custom erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Feb 20, 2024
1 parent f5eff18 commit f849902
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
description: How to use the custom functionality of ERC20NativeToken
image: /img/logo/WASP_logo_dark.png
tags:
- native token
- erc20
- EVM
- how-to
---

# Custom ERC20 Functions

Once you [registered your native token as ERC20](./erc20-native-token.md) you can use it like any other ERC20 token, with functions like
`transfer`, `balanceOf`, etc. But, as the ERC20 token maps the native token on L2, there are some additional ISC features
you can take advantage of.

## Example Code

### Get Your `ERC20NativeTokens` Instance

You can use the `erc20NativeTokensAddress` function and the Foundry serial number to get the contract address:

```solidity
ERC20NativeTokens token = ERC20NativeTokens(
ISC.sandbox.erc20NativeTokensAddress(_foundrySN)
);
```

* `nativeTokenID` will give you the native token ID of the ERC20 token:

```solidity
NativeTokenID memory id =token.nativeTokenID();
```

### Full Example Code

```solidity
function nativeTokenID(uint32 _foundrySN) public view returns (bytes memory) {
ERC20NativeTokens token = ERC20NativeTokens(
ISC.sandbox.erc20NativeTokensAddress(_foundrySN)
);
NativeTokenID memory id =token.nativeTokenID();
return id.data;
}
```
18 changes: 18 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/token/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
description: How to handle native tokens on L2 and use them as ERC20
image: /img/logo/WASP_logo_dark.png
tags:
- native token
- EVM
- how-to
---
import DocCardList from '@theme/DocCardList';

# Native Token and ERC20NativeToken

The IOTA L1 has functionality to create L1 tokens, also called native tokens. To use these native tokens on L2, you have
a ERC20 contract called `ERC20NativeToken`. The following guides will show you how to [create a foundry](create-foundry.md)
that can [mint your own L1 token from L2](mint-token.md), and [register](register-token.md) it as `ERC20NativeToken`,
so it can be used like any other ERC20 token with some additional features.

<DocCardList />
7 changes: 6 additions & 1 deletion docs/build/isc/v1.0.0-rc.6/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ module.exports = {
},
{
type: 'category',
label: 'Tokens',
label: 'Token',
items: [
{
label: 'Introduction',
type: 'doc',
id: 'how-tos/token/introduction',
},
{
type: 'doc',
label: 'Create a Foundry',
Expand Down

0 comments on commit f849902

Please sign in to comment.