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 NFT How To #1495

Merged
merged 36 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1c781ee
ISC - Restructure - Learn and Build (#1415)
lucas-tortora Feb 9, 2024
4c423fe
Fix broken links
Dr-Electron Feb 9, 2024
72e8de4
Isc Restructure - EVM how tos - basic contract, ERC20 , ERC721 and de…
lucas-tortora Feb 20, 2024
eeb9714
Add 'Create Foundry' how-to
Dr-Electron Feb 20, 2024
c026f34
Mint token
Dr-Electron Feb 20, 2024
fca7192
Register token
Dr-Electron Feb 20, 2024
0274a14
Allowance how tos
Dr-Electron Feb 20, 2024
cd6abf2
Custom erc20
Dr-Electron Feb 20, 2024
f7de66e
added article on testing (#1471)
lucas-tortora Feb 20, 2024
e563c2e
Format
Dr-Electron Feb 20, 2024
9871592
Get balance
Dr-Electron Feb 22, 2024
a7cce99
Fix structure
Dr-Electron Feb 22, 2024
d9ad6aa
Add Randomness how-to (#1484)
jlvandenhout Feb 22, 2024
d3dc97b
Add how to withdraw assets to L1
jlvandenhout Feb 24, 2024
f12b361
Format
Dr-Electron Feb 24, 2024
b40436d
Resolve TODOs
Dr-Electron Feb 27, 2024
f11a973
Use tabs (#1492)
jlvandenhout Feb 27, 2024
4d517ed
Remove Truffle (#1493)
jlvandenhout Feb 27, 2024
e460193
Remove Wasp CLI mentions from build (#1494)
jlvandenhout Feb 27, 2024
3b9f0b4
Small fixes
lucas-tortora Feb 27, 2024
c68bd00
fix link
lucas-tortora Feb 27, 2024
3b0bbdd
Small Fixes
lucas-tortora Feb 27, 2024
e2174d6
On... Off... On...
Dr-Electron Feb 27, 2024
aac75f3
Restructure how tos (#1500)
Dr-Electron Feb 28, 2024
fbf7e8f
expand gas and allowance explanations (#1503)
lucas-tortora Mar 4, 2024
fa94b09
Update docs/build/isc/v1.0.0-rc.6/docs/explanations/invocation.md
lucas-tortora Mar 4, 2024
264818c
Apply suggestions from code review
lucas-tortora Mar 7, 2024
188eb42
removed glossary tooltip in sandbox.md
lucas-tortora Mar 7, 2024
f2eca4b
fix typo
lucas-tortora Mar 7, 2024
cfcae20
Rebase on main to sort out conflicts
lucas-tortora Mar 7, 2024
f4142be
HTML be gone
Dr-Electron Mar 11, 2024
2cc336b
Add NFT minting tutorial
Dr-Electron Feb 26, 2024
5df1669
Add usage example
Dr-Electron Feb 27, 2024
797d300
Add sidebar and restructure
Dr-Electron Mar 11, 2024
ed123c7
Merge branch 'main' into nft-how-to
Dr-Electron Mar 25, 2024
b1876d5
Apply suggestions from code review
Dr-Electron Mar 26, 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
Prev Previous commit
Next Next commit
Add how to withdraw assets to L1
  • Loading branch information
jlvandenhout authored and lucas-tortora committed Mar 7, 2024
commit d3dc97b57a83592edb2ce268fc348b42b538ed24
2 changes: 1 addition & 1 deletion docs/build/isc/v1.0.0-rc.6/docs/how-tos/introduction.md
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ functionality into your projects easier.

To make the most of the how-to guides in this section, identify the specific topic or functionality you want to explore.
Whether you want to [get funds on L2](EVM/send-funds-from-L1-to-L2.md), [add ISC specific functionality](magic.md),
or [send funds to L1](send-tokens-to-l1.mdx), you can find dedicated guides that walk you through the process.
or [send funds to L1](send-assets-to-l1.mdx), you can find dedicated guides that walk you through the process.

With the how-to guides in the IOTA SDK, you can overcome implementation hurdles and gain a deeper understanding
of the IOTA ecosystem. These guides empower you with the knowledge and practical examples to seamlessly integrate IOTA
64 changes: 64 additions & 0 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/send-assets-to-l1.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
description: The ISC Magic Contract allows EVM contracts to access ISC functionality.
image: /img/logo/WASP_logo_dark.png
tags:
- configure
- using
- EVM
- magic
- Ethereum
- Solidity
---

import AboutAccounts from '../_admonitions/_about-accounts.md';

# Send Assets and Tokens to L1

<AboutAccounts/>

This guide will show you how to use the ISC sandbox interface to send assets from L2 to L1. This includes base tokens, native tokens, and NFTs. Before you can send these assets, you need to know how you get them on L2 and how you allow a contract to use them.

Note that assets on L1 require a storage deposit; therefore, the number of base tokens sent to L1 should cover at least the storage deposit required to hold the assets on L1.

## Example Code

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

pragma solidity ^0.8.0;

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

contract L1Assets {
function withdraw(L1Address memory to) public {
ISCAssets memory allowance = ISC.sandbox.getAllowanceFrom(msg.sender);
ISC.sandbox.takeAllowedFunds(msg.sender, allowance);

ISCSendMetadata memory metadata;
ISCSendOptions memory options;
ISC.sandbox.send(to, allowance, false, metadata, options);
}
}
```

## Explanation

First, you will find out what assets this contract is allowed to take from the caller by calling the `ISC.sandbox.getAllowanceFrom()` function.

```solidity
ISCAssets memory allowance = ISC.sandbox.getAllowanceFrom(msg.sender);
```

Then you take the allowance, which will transfer the assets from the caller to the contract.

```solidity
ISC.sandbox.takeAllowedFunds(msg.sender, allowance);
```

Finally, you can send the assets to the specified L1 address. This will create an output to hold said assets. You can use additional options to add the [timelock](/learn/protocols/stardust/core-concepts/output-unlock-conditions/#timelock) and [expiration](/learn/protocols/stardust/core-concepts/output-unlock-conditions/#expiration) unlock conditions to the output.

```solidity
ISCSendMetadata memory metadata;
ISCSendOptions memory options;
ISC.sandbox.send(to, allowance, false, metadata, options);
```
58 changes: 0 additions & 58 deletions docs/build/isc/v1.0.0-rc.6/docs/how-tos/send-tokens-to-l1.mdx

This file was deleted.

4 changes: 2 additions & 2 deletions docs/build/isc/v1.0.0-rc.6/sidebars.js
Original file line number Diff line number Diff line change
@@ -163,8 +163,8 @@ module.exports = {
},
{
type: 'doc',
label: 'Send Tokens to L1',
id: 'how-tos/send-tokens-to-l1',
label: 'Send Assets to L1',
id: 'how-tos/send-assets-to-l1',
},
{
type: 'doc',