From d2c1105c2ca5bf5cb0908d906b06f7c3c7726c00 Mon Sep 17 00:00:00 2001 From: vivekjain23 <165671934+vivekjain23@users.noreply.github.com> Date: Fri, 14 Jun 2024 17:04:10 +0530 Subject: [PATCH] Update and add full contract code (#1600) * Update and add full contract code * Fix contract code --- .../token/erc20-native-token.md | 22 ++++++++---- .../core-contracts/token/mint-token.md | 28 ++++++++++----- .../core-contracts/token/register-token.md | 34 ++++++++++++++----- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/erc20-native-token.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/erc20-native-token.md index eef11254681..dfbe3d280e5 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/erc20-native-token.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/erc20-native-token.md @@ -35,11 +35,21 @@ 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; +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "@iota/iscmagic/ISC.sol"; + +contract MyNativeToken { + + function nativeTokenID(uint32 _foundrySN) public view returns (bytes memory) { + ERC20NativeTokens token = ERC20NativeTokens( + ISC.sandbox.erc20NativeTokensAddress(_foundrySN) + ); + NativeTokenID memory id = token.nativeTokenID(); + return id.data; + } } + ``` diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/mint-token.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/mint-token.md index bd79533d844..551452802db 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/mint-token.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/mint-token.md @@ -29,13 +29,25 @@ ISC.accounts.mintNativeTokens(_foundrySN, _amount, allowance); ## Full Example Code ```solidity -event MintedNativeTokens(uint32 foundrySN, uint amount); - -function mintNativeTokens(uint32 _foundrySN, uint _amount, 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.accounts.mintNativeTokens(_foundrySN, _amount, allowance); - emit MintedNativeTokens(_foundrySN, _amount); +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "@iota/iscmagic/ISC.sol"; + +contract NativeTokenMinter { + event MintedNativeTokens(uint32 foundrySN, uint amount); + + function mintNativeTokens(uint32 _foundrySN, uint _amount, 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.accounts.mintNativeTokens(_foundrySN, _amount, allowance); + + emit MintedNativeTokens(_foundrySN, _amount); + } } + ``` diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/register-token.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/register-token.md index 990ae5e69b3..6e3af8a789f 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/register-token.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/token/register-token.md @@ -43,14 +43,32 @@ address erc20address = ISC.sandbox.erc20NativeTokensAddress(_foundrySN); ### Full Example Code ```solidity -event ERC20Address(address erc20address); +// SPDX-License-Identifier: MIT -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); +pragma solidity ^0.8.0; + +import "@iota/iscmagic/ISC.sol"; + +contract ERC20NativeTokenRegistry { + + 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); + } } ```