---
# System prepended metadata

title: 'Encode Club NEAR Bootcamp - DAY 10 [28/01/2022]'
tags: [bootcamp transcripts]

---

# Encode Club NEAR Bootcamp - DAY 10 [28/01/2022]
---
## [Day 10 Recording](https://youtu.be/Yzbp60nUtps)
---
# DEMO OF PROJECTS
---
## BUSINESS CARD:

-- The idea of project is business card on blockchain and its only access by owner and others can work on it.

![](https://i.imgur.com/QCxDSzA.png)

-- The cost to deploy the contract to the chain is 5N.
![](https://i.imgur.com/hnm3VPb.png)

-- Firstly going to add an website url in set website box then the idea was like adding blockchain that you can develop on the app as a blockchain experience.

-- Faced a issue on returning the array for tweets so try to return the presistent vector i cant afterwards i figured out by populate to new array and return it instread

-- Now trying to type some random stuff in add blockchain box to check if shows error.

![](https://i.imgur.com/h97MmGM.png)

so it show smart contract panicked and invalid blockchain (on the right hand side of screen.so this way only you can add registed blockchain which is added in contract.

-- once you add valid blockchain you could able to see in the claimed experience like NEAR and ETHEREUM.

![](https://i.imgur.com/zkCUBp8.png)

-- so this claimed experience part is to that somebody else come into your business card they would able to say  or vouch to me that i had ethereum experience he would add vouch if no then he will add refuse this way a count will be add next to blockchain name.

![](https://i.imgur.com/XbUNHDG.png)

-- so the main idea was to have directory of business cards that can be browse through to  to hire somebody.

**Contract:** 

-- The contract is written in rust. one of the biggest challenges is learning the data structure to use in lookup map,serialization,deserialization.

![Running unit test ](https://i.imgur.com/KsnpDWA.png)

-- The main idea was to query all the log with graph and show on frontend. when somebody clicks on more info it shows who has given him vouch and who is gave him refuse and then you can able to refined whether this person capable of doing the work or stuff.

Helpful resource: near-sdk.io 

---

## NFT Gateway

-- The Project was to allow the user to check the resources available if one hold the Gateway NFT in there account.

![](https://i.imgur.com/Zxk9AuU.png)

-- click on login and if the account has GatewayNFT it allows the access and show continue to Resource.
![](https://i.imgur.com/VfHlkQG.png)

--But if the account that doesnt have Gateway NFT it say to get access the resource need to buy Gate NFT.

![](https://i.imgur.com/Coc9Vk7.png)

-- This page shows an option to buy NFT.

![](https://i.imgur.com/UUzOVRD.png)

-- Still working on it but if i try to buy NFT it throws an error.
![](https://i.imgur.com/XBPrFUz.png)

-- The main usecase is to build this out as community engagement tool were you can connect with discord and with the help of NFT can have the access to channel or grand roles and addition to any other protective content.

**Contract**

-- Here two projects are used form the github (starter & NFT).

![](https://i.imgur.com/oDWawH9.png)

--The main page index is conntecting to wallet in contract and the contract that deployed is NFT examples.

-- The main method for Gate is NFT tokens for owner so you connect the wallet check this method to see if you have NFT it will comes back with array also making sure the array length is greater than zero.

![](https://i.imgur.com/zIjenE1.png)

-- The second part is minting were the NFT transfer function work which is not working right now.

**Lessons learned**
* Vast number of content is available in NEAR like githubs,videos were how the work flow goes and what tools they use are very useful.

---

## NEAR Dice Game

-- Project was simple dice game were user can create a dice room and another user can join the random dice that going to generated if they guess correctly they get whole part of NEAR token.

![](https://i.imgur.com/H0Zjzbe.png)

-- once you try to create room it will ask for NEAR token to submit.

![](https://i.imgur.com/9IVeY4p.png)

-- once it approved the room will be created and once the other user joined the room now you can play game by guessing the number.

![](https://i.imgur.com/fyrY5j7.png)

-- so if the number is submitted the contract will generate the number and the results will shows who won it.

![](https://i.imgur.com/Kq2Tsba.png)

-- The person who created the room can only reactivate it so others can play or they can delete the game.

**Contract**

-- Created a class for the game for the owner and player the assert function is used to create the game in order to have valid amount tokens.

![](https://i.imgur.com/L8ZbML5.png)

-- Used ordered map instead of regular map to fetch the data after it displayed in frontend.

![](https://i.imgur.com/RGmPSPR.png)

-- Once they guess a random number is generated and who ever guess correctly gets the amount transfered to them.

-- The `game.state` is used if the game is not finished and we dont stop users from playing so people can play again and again and creator will not put any mor tokens into it will take from contact itself.

![](https://i.imgur.com/0QAdnzV.png)

---

## Fungible token Creator

 --The project actually from tutorial [NEAR Submission Reddit's scaling bakeoff](https://vitalpoint.ai/course/project-overview/)  a normal wallet like eip1519 on ethereum were tokens are burned that transaction running toward null account (so no one will access to it).
 
 -- ERC20 application is running on NEAR.You can create a own token and give it symbol, precision, and initial supply its all about creating a fungible tokens.

![](https://i.imgur.com/2cgbQq1.png)

-- Created a 1000 token on chain and all the console is logging in perfectly like transfer tokens,trasfer ownership,mint tokens and burn tokens.so now trying to transfer 100 tokens to address.

![](https://i.imgur.com/1OsnA01.png)

-- Now trying to burn tokens once it done you can see that token are gone down from current balance. 

![](https://i.imgur.com/dzbz1gd.png)

From this statics you can see the burned tokens are sended to some null address (0x0). so that what the DEMO is about.

**Coding**

-- The code which builds is starting with Create-near-app which creates contract folder which lot confusion so this a project with in a project own as package.json which gives problem when running in sdk.so the problem is only run in older version sdk if we use current version 3.1 it wont work and get an error.

![](https://i.imgur.com/tzzXfIL.png)

-- So it throws type error to overcome this i have done the process of uninstall and re-installing the sdk.

![](https://i.imgur.com/vLe50wB.png)

-- In tutorials there is so much activity on javascripts in terms of packages and maturation devlopment.

![](https://i.imgur.com/5WgCwcS.png)

-- In the end deploy the contract manually by taking control of it so i delete the contract account and create it on the command line,compile the contract and then deploy the contract to account created.

![](https://i.imgur.com/bwIVA8i.png)

---

## NEAR Deposit

-- The Demo of the project is that you can deposit NEAR into the contract and you can specify a lock period and then you can get you money back the lock period end.

-- So, Firstly calling the deposit method of the contract and providing a lock period in 2 minutes and sending 5NEAR to the contract for deposit.

![](https://i.imgur.com/TMJax7S.png)

-- Now trying to call withdrawal method on the contract by specify a higher gas amount(which is more than the default amount)

![](https://i.imgur.com/j3ON73N.png)

-- you could see that it failed by by expressing your deposit will be able to withdraw after 1:16sec.

-- Now after the time period is completed trying to withdraw the tokens back to account and its successfully executed without an error.

![](https://i.imgur.com/9eIhENh.png)


**Contract**

-- The concept learned is how the time works and make cross - contract call also much about context  concept.

![](https://i.imgur.com/c3kMYtp.png)

-- Made a little read me like add fungible token support,nft support,buil/deploy scripts,mulitple points per user charge per data also simulation test and stuff like that really need to understand to become a blockchain developer

![](https://i.imgur.com/Hv1J02l.png)

---

## Decentralized Patreon

-- The main idea of the project is you can create a profile it store with the accountid of whoever is creating a profile.

-- The profile can be creator or consumer and then you can store content or tags depend on what you want also if you are creative dot subscribers which stores in the account id and cost is for subscriber to access your content.

![](https://i.imgur.com/JWVnGwJ.png)

-- The output of the application is first it add profile for the testnet account (baltion.testnet) with a gas fee and then get profile is to check that it works like profile object

![](https://i.imgur.com/6iZmdfo.png)

-- Adding some content like date and then string to test of adding content.when calling get content it gets call from profile owner which gets the content in return.

![](https://i.imgur.com/vjkrIrB.png)

-- Then when we call get content from someone who is not a subscriber and it get fails with that reason so we are going to subscribe using to developer account that returns the content.

![](https://i.imgur.com/PEEYUQN.png)

### About Borsh:

* Check out NEAR-sdk.io NEAR-sdk-rs  --> Repository --> help which contains document there with clarification about how the think about borsh serialization and deserialization.

* Basically at function boundries the parameters and return values and at storage boundries were reading and writing data to chain on those two boundries you need to make a decision how to borsh serialize and deserialize the data.

---

## NTwitter

-- The application is basically a Twitter clone. Firstly trying to login using NEAR testnet account. 

![](https://i.imgur.com/IcZtQgd.png)

-- Once done that trying to add a tweet to account and now you will see the result in recent tweets "Hello World".

![](https://i.imgur.com/yOrElTV.png)

-- While you on twitter you can go different pages by adding the account name in a search bar which leads to account that exist with recent tweets on it and if we add something else it will show user is not found.

![](https://i.imgur.com/8yfucF7.png)

**Contract**

-- Started the coding with assembly script using github repo and made some modification in view function and change function by adding some logic and coded with different examples using NEAR github page.

![](https://i.imgur.com/S1wlPOl.png)

-- One issue i can't figured out for sometime is actually want to return the array like tweet so tried to return the persistent vector but i cant do it so i populate into new array and return instead.

![](https://i.imgur.com/lUUMWKP.png)

---

## Academic Certificates

-- Project was based on generating academic certificate. Also consult the list of NFT that already minted.

![](https://i.imgur.com/lyt2UW5.png)

-- By filling the details in create page and selecting mint i will shows result in answer tab were able to see the transaction link and storing the image certificate on server.

![](https://i.imgur.com/f5yNxla.png)

![](https://i.imgur.com/Yvx3kec.png)

-- Now with the help of NFT page able to see list of NFT minted 

![](https://i.imgur.com/7yPrX7a.png)

**Contract**

-- Decided to start coding by accessing the blockchain with bash scripts written using python. Tried two functions one is NFT mint and another is NFT tokens for owners to check the list of NFT.
 
![](https://i.imgur.com/ALuvCFF.png)

-- I have  to rewrite the script everytime to create a NFT, so tried creating the script manually to control it.

![](https://i.imgur.com/o2FE6zH.png)

---

## Snipe the Block

--The project is based on getting something work and done there by expanding on lottery ideas.The application is simple When user enters the site there he able to see current block height and there are basically trying to guess which is the block they are going to execute there transaction.

![](https://i.imgur.com/WmJESpA.png)

--Firstly try to guess the block and shoot it once done it returns the block is under shot and block difference are shown.

![](https://i.imgur.com/Dkn9eRU.png)

--Basically once you guess the correct block that gets your transaction and you should be rewarded in NEAR.

**Contract**

-- On contact basically have one function which probably transferred as a switch case that does some assumption and throws the status, so i plan on updating the frontend through the `game.status`.

![](https://i.imgur.com/K829nES.png)

-- For frontend used tailwind and open.js to build the application.

---

## Decentralized Petition

-- The Contract is based on opening petition.

-- Firstly call the contract which is named with devdeploy testnet account and now trying to call the method which is Create petition method.

-- Now it takes the petition to be funded or not if its funded petition it takes the minimum fund amount else it wont the account id is same as contact.

-- Here you could see the difference between funded and not funded by intializing true or false.

![](https://i.imgur.com/Drt6pNs.png)

-- It also has different method like decide to sign a petition. so i tried to sign the funded petition with some NEAR once i call the method it get some minimum amount from petition gets sign and shows true.

![](https://i.imgur.com/2dCRoPa.png)

--But if i tried to sign the same petition with no amount deposit then execution will fail and shows error.

-- Now trying to sign the petition which in un-funded so i wont attach any deposit because its not funded so it gets successful and returned true.

-- Trying to call methods like status method gives  the high level metadata of contract and view state gives the storage/status of contract in json.

![](https://i.imgur.com/qFWtDDz.png)

-- This is status of storage on contract which is encoded in base64.

![](https://i.imgur.com/OA5b6pZ.png)

-- Trying to Decode the json code 

![](https://i.imgur.com/tFTq7W6.png)

-- The idea was that each petition to have its own presistent vector that show who as signed but later i discovered that presistent vector shared accross the blockchain in contract. so what i done is prefixed the signature by the petition id as index.

> For cross-contract calls check the bitly near.xcc and also docs.near.org you can learn about storage collection, data collection and presistent collection 
> There is one storage in your account if you put contact in to account it has one storage with key value pair and that storage is shared.

> The way the contract works is it wakes up does it work and go to sleep if it wakes up it check the storage if same one that it had before thats the idea of one storage shared across all petition.

---

## Simple 2-of-2 Multisig wallet

-- The Multisig wallet is simple that basically creates contract for two owners for this wallet and then anyone can deposit into wallet but to send some money to someone else you need a approval from both owners.

-- Firstly done the deployment and trying to deposit using simple call of deposit method with some attached amount.

![](https://i.imgur.com/Qhr3stF.png)

-- Next, is going to do withdrawl with only first owner by approving it but it doesn't actually do the trasfer (account id is first owner). Recording the approval in storage.

![](https://i.imgur.com/m1SL6cS.png)

-- Now trying to call the second owner for apporval the amount has to be match to do withdraw amount.

-- For frontend is simple ui so by loging as account you can deposit and withdraw.for withdraw amount were both the owners has to withdraw amount so the amount get transfer.

![](https://i.imgur.com/89bNeOD.png)

---

## Adopt Me

-- The project is extended version of pet shop from truffle tutorial build on NEAR. The app were you can login and add pet available for adoption were it can be adopt the pet or donate some NEAR.

-- Once login you can add data for pet buy it for adoption and if the pet is already adopted you can see it on pet card.Also you can add some NEAR for donation

![](https://i.imgur.com/c5rv2GD.png)

**Contract**

-- Here just define the contract and pet structure also added the contract for pet, adopt and donate method.

-- learned how to update field in custom structure and which strored in another structure also tried to connect NEAR contract to vue ui.

## How to put data and model it on WEB 3 ? 
*  Two option are there you can put data on the blockchain or off the blockchain.

* Off the blockchain has databases,storage drives, and file systems in the web2 world.

* But in Web 3 you have decentralized storages like ipfs,filecoin,cssky,etc are decentralized mechanism when we put data we get hash or build as a blockchain contract 

* In blockchain if the data published it will be visible to eveyone like public data and also cost some amount for read and write the data.

* So for example images are not good idea to put in blockchain because it going to cost more for read and write it and also take lot of storage init.

* But you could put images on some  web2 or web3 store and get some kind of hash or reference and put it into contract.

---


###### tags: `bootcamp transcripts`













































