Skip to content

Commit

Permalink
Update and add full contract code (#1600)
Browse files Browse the repository at this point in the history
* Update and add full contract code

* Fix contract code
  • Loading branch information
vivekjain23 authored Jun 14, 2024
1 parent c0c0469 commit d2c1105
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
```

0 comments on commit d2c1105

Please sign in to comment.