Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This loyalty smart contract will allow us to implement the loyalty program for o

Let’s look at how you will interact with the contract by the end of the course.

![interact-gif-3.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/What%20Are%20We%20Building%20Today/interact-gif-3.gif?raw=true)
![interact-gif-3.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/What%20Are%20We%20Building%20Today/interact-gif-3.webp?raw=true)

## Course Overview

Expand All @@ -35,7 +35,7 @@ As a developer, you will be getting the following outcomes when you complete thi

If you complete this course with me, you will be getting XPs and a special NFT which will unlock many more opportunities for you on the Metaschool platform. Here is what the NFT looks like.

![course-gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/assets_for_sui_c1/What%20Are%20We%20Learning%20Today%3F/image.gif?raw=true)
![course-gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/assets_for_sui_c1/What%20Are%20We%20Learning%20Today%3F/image.webp?raw=true)

Now before we move forward, let’s set some house rules first.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The command will generate a folder named `loyalty` and it will contain a file `M

Navigate to the `sources/` directory. Create a new Move file called `loyalty.move`. Here’s what the will look like:

![loyalty-structure.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20Environment/loyalty-structure.png?raw=true)
![loyalty-structure.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20Environment/loyalty-structure.webp?raw=true)

## Check your wallet

Expand All @@ -57,7 +57,7 @@ If you do not have an active address, follow the steps given below:

It will generate the output something like this:

![deploy-5.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20Environment/deploy-5.png?raw=true)
![deploy-5.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20Environment/deploy-5.webp?raw=true)

- **Important**: Save the recovery phrase, it is important to have it to import your wallet.
1. Replace `[YOUR_ADDRESS]` in the command below with the address you received after running the last command and run it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ sui move build

Here’s what the output will look like.

![output-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-1.png?raw=true)
![output-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-1.webp?raw=true)

### Step 3

Expand All @@ -106,7 +106,7 @@ sui client publish --skip-dependency-verification --gas-budget 90000000

We will have a long output but scroll to the start of the output and copy the Transaction Digest:

![output-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-2.png?raw=true)
![output-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-2.webp?raw=true)

- **Note**: If you encounter an “Insufficient funds” error then you can head over to the [Sui Testnet faucet discord channel](https://discord.com/channels/916379725201563759/1037811694564560966) and paste “!faucet [YOUR_ADDRESS]” to receive 10 SUI tokens.

Expand All @@ -116,7 +116,7 @@ We will have a long output but scroll to the start of the output and copy the Tr

Head over to [https://suiexplorer.com/?network=testnet](https://suiexplorer.com/?network=testnet). Paste the Transaction Digest in the search bar to find your transaction on the Sui Explorer:

![output-3.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-3.png?raw=true)
![output-3.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Deploying%20the%20Loyalty%20DApp/output-3.webp?raw=true)

## Wrap up

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ git clone https://github.com/0xmetaschool/sui-loyalty-dapp-frontend.git

The front end will have the following file structure.

![frontend-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-1.png?raw=true)
![frontend-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-1.webp?raw=true)

Let’s install our dependencies:

Expand All @@ -28,26 +28,26 @@ Next, we need to find the package ID of our `loyalty` module, that we implemente

1. Head over to the [Sui Explorer](https://suiexplorer.com/?network=testnet) and enter the Transaction Digest that you got in the last lesson in the search bar.

![frontend-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-1.gif?raw=true)
![frontend-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-1.webp?raw=true)


2. You can see the sidebar with the “Summary” heading. Please scroll to the end of the sidebar to find the “Publish” field.

![frontend-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-2.png?raw=true)
![frontend-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-2.webp?raw=true)


3. Now, open the “Object” field by clicking on the “>” sign in the “Publish” field and click on the “loyalty” module.

![frontend-gif-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-gif-1.gif?raw=true)
![frontend-gif-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-gif-1.webp?raw=true)


You will see the page something like this:
You will see the page something like this:

![frontend-3.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-3.png?raw=true)
![frontend-3.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-3.webp?raw=true)

1. Copy your package ID, as mentioned in the following screenshot. This will be your loyalty package ID that we will use in our front end.
4. Copy your package ID, as mentioned in the following screenshot. This will be your loyalty package ID that we will use in our front end.

![frontend-4.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-4.png?raw=true)
![frontend-4.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-4.webp?raw=true)


## Set up the environment variables
Expand Down Expand Up @@ -79,11 +79,11 @@ yarn dev

The command will give you an output like this:

![frontend-6.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-6.png?raw=true)
![frontend-6.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-6.webp?raw=true)

Head over to the link, the `local` field is showing to you. You will see something like this in your browser.

![frontend-5.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-5.png?raw=true)
![frontend-5.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Set%20Up%20the%20Frontend/frontend-5.webp?raw=true)

## That’s a wrap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn dev

This time try again to log in by clicking on the “Sign with Google” button. Verify your Google account and then log in. After logging in wait for a few seconds for ZK to get connected with your app. After the request is completed, you will see a page like this.

![interact-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-1.png?raw=true)
![interact-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-1.webp?raw=true)

Initially, you’ll see 0 balance in all or a few fields if you haven’t interacted with your dex dApp before. To use the loyalty dApp we must fill in the “DEX Swaps” and “DEXC Balance” fields. To fill these fields, we need to swap some tokens interchangeably.

Expand All @@ -28,29 +28,29 @@ Let’s play around with different features of our application and see how it wo

Here’s how we’re swapping the ETH tokens to USDC tokens.

![interact-gif-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-1.gif?raw=true)
![interact-gif-1.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-1.webp?raw=true)

### Swap USDC to ETH tokens

Here’s how we’re swapping the USDC tokens to ETH tokens.

![interact-gif-2.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-2.gif?raw=true)
![interact-gif-2.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-2.webp?raw=true)

After swapping the tokens, you’ll see the changes in the balance fields like the following.

![interact-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-2.png?raw=true)
![interact-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-2.webp?raw=true)

## Head over to loyalty dApp

It is time to stake your DEXC tokens to earn rewards for using the Dex app. When you stake the DEXC tokens one time, you will start earning the reward for every 2nd token swap. When you collect 5 rewards, you will become eligible for a reward.

Head over to loyalty dApp by clicking on the Loyalty dApp button on the left top corner and stake or unstake your DEXC tokens.

![interact-gif-3.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/What%20Are%20We%20Building%20Today/interact-gif-3.gif?raw=true)
![interact-gif-3.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/What%20Are%20We%20Building%20Today/interact-gif-3.webp?raw=true)

After 5 rewards, you will be eligible to collect the reward. Let's see how it works. In our case, the reward will be an NFT.

![interact-gif-4.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-4.gif?raw=true)
![interact-gif-4.gif](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/sui-loyalty-dapp/Interact%20With%20the%20Frontend/interact-gif-4.webp?raw=true)

## That’s a wrap

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ So, what are we building today? We will be building a Token Swap Defi applicatio

Let’s look at what your Dex dApp will look like.

![frontend-interact-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/1.%20Getting%20Started/assets/frontend-interact-1.png?raw=true)
![frontend-interact-1.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/1.%20Getting%20Started/frontend-interact-1.webp)

## Course Overview

Expand Down Expand Up @@ -38,7 +38,7 @@ As a developer, you will be getting the following outcomes when you complete thi

If you complete this course with me, you will be getting XPs and a special NFT that will unlock many more opportunities for you on the Metaschool platform. Here is what the NFT looks like.

![Untitled](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/assets_for_sui_c1/What%20Are%20We%20Learning%20Today%3F/image.gif?raw=true)
![Untitled](https://github.com/0xmetaschool/Learning-Projects/blob/main/assests_for_all/assets_for_sui_c1/What%20Are%20We%20Learning%20Today%3F/image.webp?raw=true)


Now before we move forward, let’s set some house rules first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Here's the scoop on how DeFi works:
3. User-friendly applications facilitate DeFi activities such as lending, borrowing, and trading, making financial interactions accessible to all.
4. Leveraging blockchain, DeFi transcends geographical barriers, allowing seamless financial interactions worldwide.

### **Goals of DeFi**
### Goals of DeFi

- **Accessibility:** Anyone with an internet connection can interact with a DeFi protocol.
- **Security and Transparency:** Everything's on the blockchain, so it's super secure, and transactions are open for all to see without revealing who you are.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Time to create files for coding, so follow the steps given below:

This is how your project structure will look like:

![Screen Shot 2024-01-29 at 4.26.19 PM.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/2.%20Setting%20Up%20the%20Development%20Environment/assets/Screen_Shot_2024-01-29_at_4.26.19_PM.png?raw=true)
![Screen Shot 2024-01-29 at 4.26.19 PM.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/2.%20Setting%20Up%20the%20Development%20Environment/Screen_Shot_2024-01-29_at_4.26.19_PM.webp)

## Check your wallet

Expand All @@ -61,7 +61,7 @@ If you do not have an active address, follow the steps given below:

It will generate the output something like this:

![deploy-5.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/2.%20Setting%20Up%20the%20Development%20Environment/assets/deploy-5.png?raw=true)
![deploy-5.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/2.%20Setting%20Up%20the%20Development%20Environment/deploy-5.webp)

- **Important**: Save the recovery phrase, it is important to have it to import your wallet.
1. Replace `[YOUR_ADDRESS]` in the command below with the address you received after running the last command and run it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ sui move build

This will generate an output like the following:

![deploy-1.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/4.%20Deploy%20the%20DApp/assets/deploy-1.png?raw=true)
![deploy-1.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/4.%20Deploy%20the%20DApp/deploy-1.webp)

**Note**: Ignore all the warnings and move forward.

After running the command, your project directory will include a `build` folder and a `Move.lock` file.

![deploy-2.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/4.%20Deploy%20the%20DApp/assets/deploy-2.png?raw=true)
![deploy-2.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/4.%20Deploy%20the%20DApp/deploy-2.webp)

### Set up the development environment

Expand All @@ -63,15 +63,15 @@ Note: When you are deploying on production, we recommend not to use the `--skip-

We will have a long output but scroll to the start of the output and copy the Transaction Digest:

![deploy-3.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/4.%20Deploy%20the%20DApp/assets/deploy-3.png?raw=true)
![deploy-3.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/4.%20Deploy%20the%20DApp/deploy-3.webp)

- **Note**: Ignore all the warnings and move forward. But if you encounter an “Insufficient funds” error then you can head over to the [Sui Testnet faucet discord channel](https://discord.com/channels/916379725201563759/1037811694564560966) and paste “!faucet [YOUR_ADDRESS]” to receive 10 SUI tokens.



Head over to [https://suiexplorer.com/?network=testnet](https://suiexplorer.com/?network=testnet). Paste the Transaction Digest in the search bar to find your transaction on the Sui Explorer:

![deploy-4.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/4.%20Deploy%20the%20DApp/assets/deploy-4.png?raw=true)
![deploy-4.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/4.%20Deploy%20the%20DApp/deploy-4.webp)

Whoo! You did great but wait! Now you need to create the pool. A pool is something that will fill your dex app with tokens. To do this, we need to run the following functions present in `sources/dex.move` file.

Expand All @@ -81,7 +81,7 @@ Whoo! You did great but wait! Now you need to create the pool. A pool is somethi

Here’s the screenshot of these functions from the `sources/dex.move` file.

![pool-code.png](https://github.com/0xmetaschool/Learning-Projects/blob/ba2ce8dea0997931621928704f03f1a8483ecc0d/Build%20the%20Token%20Dex%20DApp/4.%20Deploy%20the%20DApp/assets/pool-code.png?raw=true)
![pool-code.png](https://raw.githubusercontent.com/0xmetaschool/Learning-Projects/refs/heads/main/assests_for_all/Build%20the%20Token%20Dex%20DApp%20on%20Sui%20C4/4.%20Deploy%20the%20DApp/pool-code.webp)

To run these functions we need 100 SUI tokens in our testnet wallet address. It is almost impossible to get 100 SUI tokens for free even for the testnet account.

Expand Down
Loading