Skip to content

Commit

Permalink
typos from tezos.com
Browse files Browse the repository at this point in the history
  • Loading branch information
zamrokk committed Sep 25, 2023
1 parent a9ed7bb commit 31939fa
Showing 1 changed file with 33 additions and 40 deletions.
73 changes: 33 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ Training n°2 for NFT marketplace

![https://img.etimg.com/thumb/msid-71286763,width-1070,height-580,overlay-economictimes/photo.jpg](https://img.etimg.com/thumb/msid-71286763,width-1070,height-580,overlay-economictimes/photo.jpg)

This time we will add the ability to buy and sell NFT!
This time we will add the ability to buy and sell an NFT!

# :arrow_forward: Go forward

Keep your code from previous training or get the solution [here](https://github.com/marigold-dev/training-nft-1/tree/main/solution)
Keep your code from the previous lesson or get the solution [here](https://github.com/marigold-dev/training-nft-1/tree/main/solution)

> If you clone/fork a repo, rebuild locally
Expand All @@ -21,11 +19,11 @@ yarn install
cd ..
```

# :scroll: Smart contract
## :scroll: Smart contract

Add these code sections on your `nft.jsligo` smart contract
Add the following code sections on your `nft.jsligo` smart contract

1. Add offer type
Add offer type

```ligolang
type offer = {
Expand All @@ -34,7 +32,7 @@ type offer = {
};
```

2. Add `offers` field to storage
Add `offers` field to storage

```ligolang
type storage =
Expand All @@ -49,12 +47,12 @@ type storage =
};
```

Explanations:
Explanation:

- an `offer` is an NFT _(owned by someone)_ with a price
- `storage` has a new field to store `offers`: a `map` of offers

Also update the initial storage on file `nft.storageList.jsligo` to add `offers` field
Update also the initial storage on file `nft.storageList.jsligo` to initialize `offers`

```ligolang
...
Expand All @@ -68,7 +66,7 @@ Finally, compile the contract
TAQ_LIGO_IMAGE=ligolang/ligo:0.73.0 taq compile nft.jsligo
```

## :credit_card: Sell at an offer price
### :credit_card: Sell at an offer price

Define the `sell` function as below:

Expand Down Expand Up @@ -116,13 +114,13 @@ const sell = ([token_id, price]: [nat, nat], s: storage): ret => {
};
```

Explanations:
Explanation:

- User must have enough tokens _(wine bottles)_ to place an offer
- the seller will set the NFT marketplace smart contract as an operator. When the buyer send his money to buy the NFT, the smart contract will change the NFT ownership _(it is not interactive with the seller, the martketplace will do it on behalf of the seller based on the offer data)_
- the seller will set the NFT marketplace smart contract as an operator. When the buyer sends his money to buy the NFT, the smart contract will change the NFT ownership _(it is not interactive with the seller, the martketplace will do it on behalf of the seller based on the offer data)_
- we update the `storage` to publish the offer

## :credit_card: Buy a bottle on the marketplace
### :credit_card: Buy a bottle on the marketplace

Now that we have offers available on the marketplace, let's buy bottles!

Expand Down Expand Up @@ -176,13 +174,13 @@ const buy = ([token_id, seller]: [nat, address], s: storage): ret => {
};
```

Explanations:
Explanation:

- search for the offer based on the `token_id` or return an error if it does not exist
- check that the amount sent by the buyer is greater than the offer price. If it is ok, transfer the offer price to the seller and transfer the NFT to the buyer
- remove the offer as it has been executed

## Compile and deploy
### Compile and deploy

We finished the smart contract implementation of this second training, let's deploy to ghostnet.

Expand All @@ -199,9 +197,9 @@ taq deploy nft.tz -e "testing"
└──────────┴──────────────────────────────────────┴───────┴──────────────────┴────────────────────────────────┘
```

**:tada: Hooray! We have implemented and deployed the smart contract (backend) :tada:**
**We have implemented and deployed the smart contract (backend)!**

# :performing_arts: NFT Marketplace front
## :performing_arts: NFT Marketplace front

Generate Typescript classes and go to the frontend to run the server

Expand Down Expand Up @@ -533,43 +531,39 @@ export default function OffersPage() {
}
```

Explanations :
Explanation :

- the template will display all owned NFTs. Only NFTs belonging to the logged user are selected
- for each nft, we have a form to make an offer at a price
- if you do an offer, it calls the `sell` function and the smart contract entrypoint `nftContrat?.methods.sell(BigNumber(token_id) as nat,BigNumber(price * 1000000) as nat).send()`. We multiply the XTZ price by 10^6 because the smartcontract manipulates mutez.
- for each NFT, we have a form to make an offer at a price
- if you do an offer, it calls the `sell` function and the smart contract entrypoint `nftContrat?.methods.sell(BigNumber(token_id) as nat,BigNumber(price * 1000000) as nat).send()`. We multiply the XTZ price by 10^6 because the smart contract manipulates mutez.

## Let's play : Sell

1. Connect with your wallet an choose `alice` account (or one of the administrators you set on the smart contract earlier). You are redirected to the Administration /mint page as there is no nft minted yet
1. Connect with your wallet and choose `alice` account (or one of the administrators you set on the smart contract earlier). You are redirected to the Administration /mint page as there is no NFT minted yet

2. Enter these values on the form for example :

- `name`: Saint Emilion - Franc la Rose
- `symbol`: SEMIL
- `description`: Grand cru 2007

3. Click on `Upload an image` an select a bottle picture on your computer

4. Click on Mint button
3. Click on `Upload an image` and select a bottle picture on your computer

Your picture will be pushed to IPFS and be displayed, then your wallet ask you to sign the mint operation.
4. Click on the Mint button

- Confirm operation
Your picture will be pushed to IPFS and displayed, then your wallet ask you to sign the mint operation.

- Wait less than 1 minute until you get the confirmation notification, the page will automatically be refreshed.
5. Now, go to the `Trading` menu and the `Sell bottles` submenu.

5. Now, go to the `Trading` menu and the `Sell bottles` sub menu.

6. Click on the sub-menu entry
6. Click on the submenu entry

![sell.png](./doc/sell.png)

You are owner of this bottle so you can create an offer to sell it.
You are the owner of this bottle so you can create an offer to sell it.

- Enter a price offer
- Click on `SELL` button
- Wait a bit for the confirmation, then after auto refresh you have an offer for this NFT
- Wait a bit for the confirmation, then after auto-refresh you have an offer for this NFT

## Wine Catalogue page

Expand Down Expand Up @@ -806,26 +800,25 @@ export default function WineCataloguePage() {
## Let's play: Buy some wine!
Now you can see on `Trading` menu the `Wine catalogue` sub menu, click on it.
Now you can see on `Trading` menu the `Wine catalogue` submenu, click on it.
![buy.png](./doc/buy.png)
As you are connected with the default administrator you can see your own unique offer on the market
- Disconnect from your user and connect with another account who has enough XTZ to buy the bottle
- The buyer can see that alice is selling a bottle
- Buy the bottle by clicking on `BUY` button
- Disconnect from your user and connect with another account that has enough tez to buy the bottle
- The buyer can see that Alice is selling a bottle
- Buy the bottle by clicking on the `BUY` button
- Once confirmed, the offer is removed from the market
- Click on `bottle offers` sub menu
- You are now the owner of this bottle, you can resell it at your own price, etc ...
# :palm_tree: Conclusion :sun_with_face:
You created an NFT collection marketplace from the ligo library, now you can buy and sell NFTs at your own price.
You created an NFT collection marketplace from the Ligo library, now you can buy and sell NFTs at your own price.
This concludes the NFT training!
On next training, you will see another kind of NFT called `single asset`. Instead of creating x token types, you will be authorize to create only 1 token_id 0, on the other side, you can mint a quantity n of this token.
In the next lesson, you will see another kind of NFT called `single asset`. Instead of creating _X_ token types, you will be allowed to create only 1 token_id 0, on the other side, you can mint a quantity _n_ of this token.
[:arrow_right: NEXT (HTML version)](https://marigold-dev.github.io/training-nft-3)
Expand Down

0 comments on commit 31939fa

Please sign in to comment.