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 docs for wasp 1.4.0 #1683

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions config/versionedConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ exports.buildPluginsConfig = [
subsection: 'build-layer-2',
versions: [
{
label: 'v1.1',
banner: 'unmaintained',
label: 'v1.3',
badges: ['IOTA'],
},
{
label: 'v1.3',
badges: ['IOTA', 'Shimmer', 'Testnet'],
label: 'v1.4',
badges: ['Shimmer', 'Testnet'],
},
],
},
Expand Down Expand Up @@ -153,12 +153,12 @@ exports.maintainPluginsConfig = [
subsection: 'maintain-layer-2',
versions: [
{
label: 'v1.1',
banner: 'unmaintained',
label: 'v1.3',
badges: ['IOTA'],
},
{
label: 'v1.3',
badges: ['IOTA', 'Shimmer', 'Testnet'],
label: 'v1.4',
badges: ['Shimmer', 'Testnet'],
},
],
},
Expand Down
5 changes: 0 additions & 5 deletions docs/build/isc/v1.1/docs/_admonitions/_mint-nft.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ functionalities, introducing commands like `isc.send(...)` for token transfers.

### Gas Fees

As in [Ethereum](https://ethereum.org/en/developers/docs/gas), gas fees depend on the current network usage. As in an
As in [Ethereum](https://ethereum.org/en/developers/docs/gas), gas fees depend on the current network usage. As in an
auction, if there is a high demand, users will compete and try to outbid each other's transactions. This means gas prices
increase in periods of high usage and decrease when the usage goes down. However, unlike Ethereum, the chain owner can set
the minimum gas fee.

<QueryGasFees />


Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,11 @@ NativeTokenID memory id =token.nativeTokenID();
### Full Example Code

```solidity
// 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;
}
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,25 +29,13 @@ ISC.accounts.mintNativeTokens(_foundrySN, _amount, allowance);
## Full Example Code

```solidity
// 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);
}
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,32 +43,14 @@ address erc20address = ISC.sandbox.erc20NativeTokensAddress(_foundrySN);
### Full Example Code

```solidity
// SPDX-License-Identifier: MIT
event ERC20Address(address 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);
}
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);
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ approve step is also required, but the operations will happen on the `ONFT` cont
- [layerZero Endpoint V1 (Mainnet)](https://docs.layerzero.network/v1/developers/evm/technical-reference/mainnet/mainnet-addresses)
- [LayerZero explorer](https://Testnet.layerzeroscan.com/)

### Install and compile the Library
### Install and Compile the Library

After you have cloned
the [IOTA Community Utilities for LayerZero ONFT V1 repository](https://github.com/iota-community/layerzero-onft-v1-utils),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,23 @@ The second part of the series will focus on bridging NFTs from another EVM netwo
Finally, in part III, you will deploy another instance of the marketplace on the BNB Testnet, making the marketplace truly cross-chain.

## Marketplace Architecture Overview

The architecture of the marketplace will evolve as we progress through the tutorials.

### Part I

In part I, we will start with this very simple architecture:

![Cross Chain MarketPlace V1](../../../../../../static/img/tutorials/cross_chain_marketplace/Architecture-V1.png)

### Part II

In Part II, you will add the contracts and scripts to manually bridge NFTs from the BNB Testnet to the ShimmerEVM Testnet and list them on the marketplace.

The architecture will evolve to look like this:

In Part II, you will add the contracts and scripts to manually bridge NFTs from the BNB Testnet to the ShimmerEVM Testnet and list them on the marketplace. The architecture will evolve to look like this:
![Cross Chain MarketPlace V2](../../../../../../static/img/tutorials/cross_chain_marketplace/Architecture-V2.png)

### Part III

Finally, in part III, you will deploy another marketplace instance on the BNB Testnet, where the contract will handle cross-chain transactions.
This enables a user on the BNB Testnet, to view and buy an NFT listed on the ShimmerEVM Testnet and vice versa without switching networks.

The architecture will look like this:

![Cross Chain MarketPlace V3](../../../../../../static/img/tutorials/cross_chain_marketplace/Architecture-V3.png)



## Prerequisites

- [Node.js](https://nodejs.org) >= v18.0
Expand Down Expand Up @@ -63,6 +54,10 @@ In the `hardhat.config.js` file, update the `networks` object to include the Shi
https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/ab11866504fe8f72fc54d719a316ec9291839ced/hardhat.config.js
```





## Contracts

In the first part of the tutorial, you will only need two contracts: the [NFT Marketplace contract](https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/ab11866504fe8f72fc54d719a316ec9291839ced/contracts/NFTMarketPlace.sol) and an [NFT ERC721-compatible](https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/main/contracts/MyERC721.sol) contract.
Expand All @@ -73,12 +68,10 @@ Create a `contracts` folder in the root of the project and add the following fil

The idea behind a marketplace contract is to allow users to list their NFTs for sale and other users to buy them. The contract will handle the transfer of the NFT from the seller to the buyer and the payment from the buyer to the seller. A seller must first allow the marketplace contract to transfer the NFT on their behalf before listing it for sale.

#### Data Structures

The main data structures and functions in the contract are:

- `struct Listing`: Represents an NFT listing with the seller's price and address. In further parts of the tutorial, `struct Listing` will be expanded to include more details about the NFT being listed, like the chain it resides on.

- `struct Listing`
Represents an NFT listing with the price and the address of the seller. In further parts of the tutorial, `struct Listing` will be expanded to include more details about the NFT being listed, like the chain it resides on.
```solidity
struct Listing {
address seller;
Expand All @@ -87,13 +80,15 @@ struct Listing {
```


- `mapping s_listings` : Maps the token contract address to a mapping of token ID to `Listing.`
- `mapping s_listings`
Maps the token contract address to a mappring of token ID to `Listing`.
```solidity
mapping(address => mapping(uint256 => Listing)) private s_listings;
```
#### Functions

- `function listItem`: Allows a seller to list an NFT for sale by specifying the token contract address, the token ID, and the price. This function will stay the same in Part II, but the `Listing` struct will be expanded to include more details about the NFT being listed, like the chain it resides on.

- `function listItem`
Allows a seller to list an NFT for sale by specifying the token contract address, the token ID, and the price. In Part II, this function will stay the same, but the `Listing` struct will be expanded to include more details about the NFT being listed, like the chain it resides on.

```solidity
/*
Expand Down Expand Up @@ -123,7 +118,11 @@ mapping(address => mapping(uint256 => Listing)) private s_listings;
}
```

- `function buyItem`: This handles the transfer of an NFT from a seller to the buyer. Similar to the `listItem` function, this function will stay the same in Part II because the NFTs will be bridged manually.



- `function buyItem`
This handles the transfer of an NFT from a seller to buyer. Same as the `listItem` function, this function will stay the same in Part II, because the NFTs will be bridged manually.

```solidity
/*
Expand Down Expand Up @@ -159,7 +158,11 @@ mapping(address => mapping(uint256 => Listing)) private s_listings;

```

- `function getListing`: Gets an NFT listing by its address and `tokenId`.



- `function getListing`
gets an NFT listing by its address and `tokenId`.
```solidity
function getListing(address nftAddress, uint256 tokenId)
external
Expand All @@ -185,7 +188,6 @@ A standard ERC721-compatible contract that allows minting and transferring of NF
```solidity reference
https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/main/contracts/MyERC721.sol
```
### Compile the Contracts

After adding the contracts, compile them by running:

Expand All @@ -199,7 +201,6 @@ npx hardhat compile
First, create a `scripts` folder in the root of the project and add the following files under it:

### deploy_marketplace_shimmer.js

The `deploy_marketplace_shimmer.js` script will deploy the NFTMarketplace contract to the ShimmerEVM Testnet and save the contract address to a file called `NFTMarketplace.txt`.

```javascript reference
Expand All @@ -213,13 +214,11 @@ npx hardhat run scripts/deploy_marketplace_shimmer.js --network shimmerevm-testn
```

### deploy_er721_shimmer.js

This script will deploy the `MyERC721` contract to the ShimmerEVM Testnet and save the contract's address to a file called `MyERC721.txt`.

```javascript reference
https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/main/scripts/deploy_erc721_shimmer.js
```

You can run this script with the following command:

```bash
Expand All @@ -233,7 +232,6 @@ After you have deployed the `MyERC721` contract, you are ready to mint an NFT us
```javascript reference
https://github.com/iota-community/ISC-Cross-Chain-NFT-Marketplace/blob/main/scripts/mint_nft.js
```

You can run the script by executing the following command:

```bash
Expand Down Expand Up @@ -279,4 +277,4 @@ npx hardhat run scripts/buy_item.js --network shimmerevm-testnet


## Conclusion
In this first part of the cross-chain NFT marketplace tutorial, you have set up the project and deployed the NFTMarketplace contract to the ShimmerEVM Testnet. You have also deployed the MyERC721 contract, minted an NFT, and listed it on the marketplace. In the next part, we will manually bridge NFTs from the BNB Testnet and Shimmer Testnet to the ShimmerEVM Testnet and list them on the same marketplace.
In this first part of the cross-chain NFT marketplace tutorial, we have set up the project and deployed the NFTMarketplace contract to the ShimmerEVM Testnet. We have also deployed the MyERC721 contract, minted an NFT and then listed it on the marketplace. In the next part, we will manually bridge NFTs from BNB Testnet and Shimmer Testnet to the ShimmerEVM Testnet and list them on the same marketplace.
File renamed without changes.
12 changes: 6 additions & 6 deletions scripts/get_wasp_references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ mkdir tmp
cd tmp

# Download and copy docs
curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.1/iscmagic.tar.gz | tar xzv
cp -Rv docs/iscmagic/* ../docs/build/isc/v1.1/docs/reference/magic-contract/

curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.1/iscutils.tar.gz | tar xzv
cp -Rv docs/iscutils ../docs/build/isc/v1.1/docs/reference/

curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.3/iscmagic.tar.gz | tar xzv
cp -Rv docs/iscmagic/* ../docs/build/isc/v1.3/docs/reference/magic-contract/

curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.3/iscutils.tar.gz | tar xzv
cp -Rv docs/iscutils ../docs/build/isc/v1.3/docs/reference/

curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.4/iscmagic.tar.gz | tar xzv
cp -Rv docs/iscmagic/* ../docs/build/isc/v1.4/docs/reference/magic-contract/

curl -sL https://s3.eu-central-1.amazonaws.com/files.iota.org/iota-wiki/wasp/1.4/iscutils.tar.gz | tar xzv
cp -Rv docs/iscutils ../docs/build/isc/v1.4/docs/reference/

# Return to root and cleanup
cd -
rm -rf tmp
Loading