<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kohwo Orien</title>
    <description>The latest articles on DEV Community by Kohwo Orien (@kels_orien).</description>
    <link>https://dev.to/kels_orien</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F37359%2F7698afa8-b6c5-481e-8186-ab91b04b92f6.jpg</url>
      <title>DEV Community: Kohwo Orien</title>
      <link>https://dev.to/kels_orien</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kels_orien"/>
    <language>en</language>
    <item>
      <title>Building a Full Stack NFT Market Place with Near Protocol and React.js Part 2</title>
      <dc:creator>Kohwo Orien</dc:creator>
      <pubDate>Thu, 19 May 2022 14:48:47 +0000</pubDate>
      <link>https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-part-2-5136</link>
      <guid>https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-part-2-5136</guid>
      <description>&lt;p&gt;For the Part 2 of this guide, we will concentrate on developing the market contract and updating the frontend. The repository for part two of this project is located &lt;a href="https://github.com/kels-orien/nft-marketplace-part-2"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the link for &lt;a href="https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-ak9"&gt;Part 1&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;The first contract &lt;code&gt;nft-contract&lt;/code&gt; enabled us to mint our NFT and transfer to wallet.&lt;/p&gt;

&lt;p&gt;The market contract we are about to create will provide a means of buying and selling NFTs in the market place.&lt;/p&gt;

&lt;p&gt;From your downloaded &lt;a href="https://github.com/near-examples/nft-tutorial"&gt;nft-tutorial&lt;/a&gt;, copy the &lt;code&gt;market-contract&lt;/code&gt; folder into your project root directory.&lt;/p&gt;

&lt;p&gt;Rename &lt;code&gt;market-contract&lt;/code&gt; to &lt;code&gt;market_contract&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your &lt;code&gt;market_contract&lt;/code&gt; folder/directory should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;market_contract

     |___ build.sh
     |____build.bat
     |___ Cargo.lock
     |___ Cargo.toml
     |___ README.md
     |___ test.sh
     |____src
           |____ external.rs
           |____ internals.rs
           |____ lib.rs
           |____ nft_callbacks.rs
           |____ sale_views.rs
           |____ sales.rs


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;external.rs&lt;/code&gt;: used for external contract calls. This will initiate a &lt;a href="https://docs.near.org/docs/tutorials/contracts/cross-contract-calls"&gt;cross contract&lt;/a&gt; call to the nft contract.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;internals.rs&lt;/code&gt;: used to generate a unique prefix for our storage collections to avoid data collisions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lib.rs&lt;/code&gt;: holds the smart contract initialization functions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nft_callbacks.rs&lt;/code&gt;: approval callbacks from the NFT contracts.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sale_views.rs&lt;/code&gt;: returns data on market place sales.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sale.rs&lt;/code&gt;: struct that holds important information about each sale on the market.&lt;/p&gt;

&lt;p&gt;update your &lt;code&gt;Cargo.toml&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[package]
name = "market_contract"
version = "0.1.0"
authors = ["Your name &amp;lt;Youraddress@mail.com&amp;gt;"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
near-sdk = "=4.0.0-pre.4"

[profile.release]
codegen-units=1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Before the &lt;code&gt;market-contract&lt;/code&gt; subaccount can be created, your near testnet wallet account wallet must contain at least a 100 near tokens. To increase your  near tokens. &lt;a href="https://wallet.testnet.near.org"&gt;create a new testnet wallet account&lt;/a&gt; and transfer required tokens to your current wallet account.&lt;/p&gt;
&lt;h3&gt;
  
  
  Build the contract
&lt;/h3&gt;

&lt;p&gt;From  &lt;code&gt;market_contract&lt;/code&gt; directory via CLI&lt;/p&gt;

&lt;p&gt;For Windows users, type :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./build.bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For Mac and Linux users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./build.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Create market subaccount
&lt;/h3&gt;

&lt;p&gt;From your &lt;code&gt;market_contract&lt;/code&gt; directory via CLI, input command:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near create-account  market_contract.youraccountname.testnet --masterAccount youraccountname.testnet

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Deploy contract
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near deploy market_contract.youraccountname.testnet --wasmFile res/market_contract.wasm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Initialize Your contract
&lt;/h3&gt;

&lt;p&gt;To initialize our market contract from CLI:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call market_contract.youraccountname.testnet new '{"owner_id": "nft-contract.youraccountname.testnet"}' --accountId youraccountname.testnet

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Windows users should remember to use backward slash("\"). &lt;/p&gt;
&lt;h3&gt;
  
  
  Updating the Frontend
&lt;/h3&gt;

&lt;p&gt;Changes were made to &lt;code&gt;App.js&lt;/code&gt; &lt;code&gt;config.js&lt;/code&gt; &lt;code&gt;useModal.js&lt;/code&gt; and &lt;code&gt;Modal.js&lt;/code&gt;. Let's discuss the changes.&lt;/p&gt;

&lt;p&gt;Let's start be updating &lt;code&gt;config.js&lt;/code&gt; &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;We are including the &lt;code&gt;MARKET_CONTRACT_NAME&lt;/code&gt; since we create a contract for the market contract.&lt;/p&gt;

&lt;h4&gt;
  
  
  useModal.js
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;useModal.js&lt;/code&gt; updated to include toggle functions that can change the states for modal sale and price.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modal.js
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;Modal.js&lt;/code&gt; updated to include states for sale and bid&lt;/p&gt;

&lt;p&gt;We are going to add the following market contract methods to the frontend's app component:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;storage_minumum_balance&lt;/code&gt;: gets the minimum required storage value needed for a sale item. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;storage_deposit&lt;/code&gt;: allows users to deposit storage. This is to cover the cost of storing sale objects on the contract.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;nft_approve&lt;/code&gt;:     approve an account ID to transfer a token on user behalf.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  App Component
&lt;/h3&gt;

&lt;p&gt;The code is rather long, use the &lt;a href="https://github.com/kels-orien/nft-marketplace-part-2/blob/main/src/App.js"&gt;link&lt;/a&gt; to update it while we discus the main changes. &lt;/p&gt;

&lt;p&gt;Let's discuss the new functions added to the app component:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;loadSaleItems&lt;/code&gt;: gets and displays all sale items in the market contract. The &lt;code&gt;get_sales_by_nft_contract_id&lt;/code&gt; gets the all items for sale by NFT contract id.  The &lt;code&gt;get_sales_by_nft_contract_id&lt;/code&gt; does not provide complete data for each sale item, comparing the results of the &lt;code&gt;nft-contract&lt;/code&gt; method &lt;code&gt;nft-token&lt;/code&gt; and &lt;code&gt;market_contract&lt;/code&gt; method &lt;code&gt;get_sales_by_nft_contract_id&lt;/code&gt; enables us to get the complete record of the sale items.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;getMinimumStorage&lt;/code&gt;: gets the storage amount needed to store a sale item using the &lt;code&gt;storage_minimum_balance&lt;/code&gt; method.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;sendStorageDeposit&lt;/code&gt;: sends storage deposit needed to store a sale item using &lt;code&gt;storage_deposit&lt;/code&gt; method.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;approveNFTForSale&lt;/code&gt;: approves the market contract to transfer an NFT token on owner behalf.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;code&gt;offerPrice&lt;/code&gt;: places an offer on a specific sale. The sale will go through as long as the deposit is greater than or equal to the list price using the &lt;code&gt;offer&lt;/code&gt; method.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Testing it out
&lt;/h3&gt;

&lt;p&gt;Change into the root directory and run the start command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>web3</category>
      <category>rust</category>
      <category>react</category>
    </item>
    <item>
      <title>Building a Full Stack NFT Market Place with Near Protocol and React.js Part 1</title>
      <dc:creator>Kohwo Orien</dc:creator>
      <pubDate>Thu, 07 Apr 2022 18:12:43 +0000</pubDate>
      <link>https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-ak9</link>
      <guid>https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-ak9</guid>
      <description>&lt;p&gt;For this guide, I decided to build an NFT Market Place using Near Protocol, although there is a much faster ways of setting up a near project using &lt;a href="https://github.com/near/create-near-app" rel="noopener noreferrer"&gt;create-near-app&lt;/a&gt;, I wanted to put the pieces together to make it easier to understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Near Protocol Overview
&lt;/h3&gt;

&lt;p&gt;Near Protocol is a Layer one(L1), developer friendly proof of stake public blockchain. Near Protocol compared to Ethereum has  significantly lower Gas fees thanks to a more efficient contract execution model. It also uses Nightshade, a dynamic approach to Sharding.&lt;/p&gt;

&lt;p&gt;Benefits of Near Protocol:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;NEAR allows transactions to be processed for an extremely low fee.&lt;/li&gt;
&lt;li&gt;Near Protocol is significantly faster than Ethereum Layer One&lt;/li&gt;
&lt;li&gt;Near features human readable addresses for contracts and accounts&lt;/li&gt;
&lt;li&gt;The use of Rust or AssemblyScript for smart contracts on the Near platform made it easy for developers to write code.&lt;/li&gt;
&lt;li&gt;Developers and users can move assets quickly thanks to the ETH-Near Rainbow Bridge.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Project Overview
&lt;/h3&gt;

&lt;p&gt;This tutorial comprises of three sections, as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part 1: Setting up the NFT Contract(Backend and Frontend)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/kels_orien/building-a-full-stack-nft-market-place-with-near-protocol-and-reactjs-part-2-5136?preview=a8d5f5fd603996ebb989078c5048a1bceb7ac0d9fe1d94bbaee7951137934554380c39f7d4a61041b3046f24f3f3b291a0abe66b2ddf7aedd49b54b8"&gt;Part 2: Setting up the Market Place(Backend and Frontend)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are going to build a Market place for both frontend and backend. &lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1
&lt;/h2&gt;

&lt;p&gt;The repository for part one of this project is located &lt;a href="https://github.com/kels-orien/nft-marketplace-part-1" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/nvm-sh/nvm" rel="noopener noreferrer"&gt;Nodejs&lt;/a&gt;: is a JavaScript runtime environment built on Chrome V8 engine. &lt;br&gt;
&lt;a href="https://wallet.testnet.near.org/" rel="noopener noreferrer"&gt;NEAR Wallet Account&lt;/a&gt;:NEAR Wallet is a secure wallet and account manager for your accounts on the NEAR blockchain. A Near wallet allows you to interact with applications on Near and securely store tokens and NFTs. For this tutorial we are using a testnet wallet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.near.org/docs/develop/contracts/rust/intro#installing-the-rust-toolchain" rel="noopener noreferrer"&gt;Rust Toolchain&lt;/a&gt;: Rust Toolchain is a particular version of a collection of programs needed to compile a Rust application it includes, but is not limited to, the compiler &lt;code&gt;rustc&lt;/code&gt;, the dependency manager and build tool, &lt;code&gt;cargo&lt;/code&gt;, the documentation generator, &lt;code&gt;rustdoc&lt;/code&gt; and the static and/ or dynamic libraries. &lt;br&gt;
&lt;a href="https://docs.near.org/docs/tools/near-cli#setup" rel="noopener noreferrer"&gt;NEAR-CLI&lt;/a&gt;: is a NodeJS command line interface that utilizes near-api-js to connect to and interact with the NEAR blockchain.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Near Protocol uses &lt;a href="https://www.rust-lang.org/" rel="noopener noreferrer"&gt;rust&lt;/a&gt; programming language for it's smart contracts. We are going to start with a rust contract template.&lt;/p&gt;

&lt;p&gt;From your CLI create a folder/directory named &lt;code&gt;nft-marketplace-part-1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enter your project root directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd nft-marketplace-part-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Clone the following rust template into your &lt;code&gt;nft-market-place-part-1&lt;/code&gt; root folder/directory:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/near-examples/rust-template.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Rename the file &lt;code&gt;rust-template&lt;/code&gt; to &lt;code&gt;nft-contract&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;update your Cargo.toml file:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[package]
- name = " rust-template"
+ name = "nft-contract"
version = "0.1.0"
- authors = ["Near Inc &amp;lt;hello@near.org&amp;gt;"]
+ authors = ["Your name&amp;lt;youraddress@mail.com&amp;gt;"]
edition = "2021"

[lib]   
- crate-type = ["cdylib"]
+ crate-type = ["cdylib", "rlib"]

[dependencies]
near-sdk = "4.0.0-pre.4"
+ serde_json = "1.0"

[profile.release]
codegen-units = 1
# Tell `rustc` to optimize for small code size.
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;By changing &lt;code&gt;name&lt;/code&gt;, we'll be changing the compiled wasm file's name after running the build script. For Windows it's the &lt;code&gt;build.bat&lt;/code&gt; for OS X and linux &lt;code&gt;build.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Download this  near protocol &lt;a href="https://github.com/near-examples/nft-tutorial" rel="noopener noreferrer"&gt;nft-tutorial&lt;/a&gt; from github. Copy the &lt;code&gt;src&lt;/code&gt; directory of &lt;code&gt;nft-contract&lt;/code&gt; folder and copy it into your new own &lt;code&gt;nft-contract&lt;/code&gt; folder .&lt;/p&gt;

&lt;p&gt;Your &lt;code&gt;nft-contract&lt;/code&gt; folder/directory should look like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nft-contract

     |___ build.sh
     |____build.bat
     |___ Cargo.lock
     |___ Cargo.toml
     |___ README.md
     |___ test.sh
     |____src
           |____ approval.rs
           |____ enumeration.rs
           |____ events.rs
           |____ internals.rs
           |____ lib.rs
           |____ metadata.rs
           |____ mint.rs
           |____ nft_core.rs
           |____ royalty.rs

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;approval.rs&lt;/code&gt;: contains functions that controls the access and transfers of non-fungible tokens.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;enumeration.rs&lt;/code&gt;: contains the methods to list NFTs tokens and their owners.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lib.rs&lt;/code&gt;: Holds the smart contract initialization functions.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;metadata.rs&lt;/code&gt;: Defines the token and metadata structure.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mint.rs&lt;/code&gt;: Contains token minting logic&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nft_core.rs&lt;/code&gt;: Core logic that allows you to transfer NFTs between users&lt;/p&gt;

&lt;p&gt;&lt;code&gt;royalty.rs&lt;/code&gt;: Contains payout related functions&lt;/p&gt;
&lt;h3&gt;
  
  
  Logging into near account
&lt;/h3&gt;

&lt;p&gt;We are going to login into near account from CLI.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is take you to the Near Wallet again where you can confirm the creation of a full-access key. Follow the instructions from the login command to create a key on your hard drive. The key will be located in your operating system's home directory in a folder called &lt;code&gt;near-credentials&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Build the contract
&lt;/h3&gt;

&lt;p&gt;From  &lt;code&gt;nft-contract&lt;/code&gt; directory via CLI&lt;/p&gt;

&lt;p&gt;For Windows users, type :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./build.bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For Mac and Linux users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./build.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Creating a subaccount
&lt;/h3&gt;

&lt;p&gt;if you have followed the prerequisites recommended, you already have a near wallet account created and NEAR CLI installed with full-access key on your machine. The next step is to create a &lt;a href="https://docs.near.org/docs/concepts/account" rel="noopener noreferrer"&gt;subaccount&lt;/a&gt; and deploy the contract to it.&lt;/p&gt;

&lt;p&gt;To create subacccount from &lt;code&gt;nft-contract&lt;/code&gt; directory via CLI run:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near create-account nft-contract.youraccountname.testnet --masterAccount youraccountname.testnet

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;youraccountname&lt;/code&gt; is the name of the testnet wallet that should have been created by you earlier.&lt;/p&gt;

&lt;p&gt;After creating the account, you can view the state with the following command:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near state nft-contract.youraccountname.testnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Your account state should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frywg4ztjzk7ey9cqxeav.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frywg4ztjzk7ey9cqxeav.PNG" alt="state of subaccount before deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note your codehash, the numbers are all ones(1s), this means that no contract has been deployed to this account, this will change when the contract is deployed.&lt;/p&gt;
&lt;h3&gt;
  
  
  Deploy the contract
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near deploy --accountId nft-contract.youraccountname.testnet --wasmFile res/nft_contract.wasm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Check your account state again:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosz31u00b39k3mhi6oe4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosz31u00b39k3mhi6oe4.PNG" alt="state of subaccount after deployment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can see that your hash changed from only ones, this is a code hash of a deployed smart contract.&lt;/p&gt;
&lt;h3&gt;
  
  
  Initialize Your contract
&lt;/h3&gt;

&lt;p&gt;To initialize our contract from CLI:&lt;/p&gt;

&lt;p&gt;For Mac and Linux Users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call nft-contract.youraccountname.testnet new_default_meta '{"owner_id": "nft-contract.youraccountname.testnet"}' --accountId nft-contract.youraccountname.testnet

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For Windows Users:&lt;br&gt;
Windows command prompt doesn't accept single quotes so we have to escape them with the backward slash("\"). See below:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call nft-contract.youraccountname.testnet new_default_meta '{\"owner_id\": \"nft-contract.youraccountname.testnet\"}' --accountId nft-contract.youraccountname.testnet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;After initializing, to view metadata via CLI, use command&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near view nft-contract.youraccountname.testnet nft_metadata
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Minting Token
&lt;/h3&gt;

&lt;p&gt;For Mac and Linux users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call nft-contract.youraccountname.testnet nft_mint '{"token_id": "token-1", "metadata": {"title": "My Non Fungible Team Token", "description": "The Team Most Certainly Goes :)", "media": "https://bafybeiftczwrtyr3k7a2k4vutd3amkwsmaqyhrdzlhvpt33dyjivufqusq.ipfs.dweb.link/goteam-gif.gif"}, "receiver_id": "youraccountname.testnet"}' --accountId youraccountname.testnet --amount 0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For Windows users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call nft-contract.youraccountname.testnet nft_mint '{\"token_id": "token-1\", "metadata": {\"title": \"My Cat Fungible Meme Token\", \"description\": \" Grumpy Cat:(\", \"media\": \"https://res.cloudinary.com/dofiasjpi/image/upload/v1649353927/near-tutorial-nfts/OIP.jpg\"}, \"receiver_id\": \"youraccountname.testnet\"}' --accountId youraccountname.testnet --amount 0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can check the &lt;a href="https://wallet.testnet.near.org/?tab=collectibles" rel="noopener noreferrer"&gt;collectibles&lt;/a&gt; section of your testnet wallet for your freshly minted NFT.&lt;/p&gt;
&lt;h3&gt;
  
  
  View NFT Information via CLI:
&lt;/h3&gt;

&lt;p&gt;For Mac and Linux users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near view nft-contract.youraccountname.testnet nft_token '{"token_id": "token-1"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For Windows users:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near view nft-contract.youraccountname.testnet nft_token '{\"token_id\": \"token-1\"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Transferring NFTs
&lt;/h3&gt;

&lt;p&gt;To transfer an NFT create &lt;a href="https://wallet.testnet.near.org/" rel="noopener noreferrer"&gt;another testnet wallet account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To transfer run command via CLI:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;near call nft-contract.youraccountname.testnet nft_transfer '{"receiver_id": "yoursecondaccountname.testnet, "token_id": "token-1", "memo": "Go Team :)"}' --accountId youraccountname.testnet --depositYocto 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this call 1 yoctoNEAR is deposited for security so that the user will be redirected to the NEAR wallet.&lt;/p&gt;

&lt;p&gt;Windows users should remember to add backslash before every quote mark like we did previously.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating the Frontend
&lt;/h2&gt;

&lt;p&gt;You can follow this nice &lt;a href="https://www.freecodecamp.org/news/how-to-up-a-react-app-with-parcel" rel="noopener noreferrer"&gt;tutorial&lt;/a&gt; to add react with parcel bundler on your &lt;code&gt;nft-marketplace-part-1/src&lt;/code&gt; directory. Create a &lt;code&gt;src&lt;/code&gt; folder/directory inside the &lt;code&gt;nft-marketplace-part-1&lt;/code&gt; and move your &lt;code&gt;index.html&lt;/code&gt; and &lt;code&gt;index.js&lt;/code&gt; inside it.&lt;/p&gt;

&lt;p&gt;From the &lt;code&gt;nft-marketplace-part-1&lt;/code&gt; directory via CLI install:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install near-api-js regenerator-runtime react-scripts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;update your the scripts sections of your &lt;code&gt;package.json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "start": "parcel src/index.html",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Entry point
&lt;/h3&gt;

&lt;p&gt;Update our &lt;code&gt;src/index.js&lt;/code&gt; file with the following code&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;We are starting with an asynchronous JavaScript function that sets up the required parameters that are passed to the React app.&lt;/p&gt;

&lt;p&gt;Let's breakdown the code above, starting with the imports.&lt;/p&gt;

&lt;p&gt;We imported from:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config.js&lt;/code&gt; This file contains details of the different networks.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;near-api-js&lt;/code&gt; We import all the functions of this dependency to &lt;code&gt;nearAPI&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const keyStore = new nearAPI.keyStores.BrowserLocalStorageKeyStore()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Creates a  keystore for signing transactions using the user's key which is located in the browser's local storage after the user logs in.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const near = await nearAPI.connect({ keyStore, ...nearConfig });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;initializing the connection to the NEAR testnet.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const walletConnection = new nearAPI.WalletConnection(near)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Initializes wallet connection&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
initContract().then(({ currentUser, nearConfig, walletConnection, near})=&amp;gt; {

  ReactDOM.render(&amp;lt;App currentUser={currentUser} nearConfig={nearConfig} walletConnection={walletConnection} near={near}/&amp;gt;,
       document.getElementById('root'));
})


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;initContract&lt;/code&gt; method is called and data is passed to the &lt;code&gt;App.js&lt;/code&gt; Component&lt;/p&gt;
&lt;h3&gt;
  
  
  App Component
&lt;/h3&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Let's start be discussing the imports:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Modal&lt;/code&gt;: is a component overlay that will enable us to add a form inside it.&lt;br&gt;
&lt;code&gt;useModal&lt;/code&gt;: uses &lt;code&gt;useState&lt;/code&gt; to open and close modal.&lt;/p&gt;

&lt;p&gt;Now let's discuss the functions:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;signIn&lt;/code&gt;: Remember we passed a &lt;code&gt;walletConnection&lt;/code&gt; object to &lt;code&gt;App.js&lt;/code&gt; Component, once logged in, the object will be tied to the logged-in user and they'll use that key to sign in transactions and interact with the contract.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;signOut&lt;/code&gt;: allows user to sign out of wallet account.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sendMeta&lt;/code&gt;: is a function call to the contract method &lt;code&gt;new_default_meta&lt;/code&gt; to set metadata, remember we used this method to set metadata when we used CLI.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;displayAllNFT&lt;/code&gt;: is a function call to &lt;code&gt;nft_tokens_for_owner&lt;/code&gt; method in the contract account which retrieves all nfts from the collectibles section of the wallet account.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mintAssetToNFT&lt;/code&gt;:  is a function call to mint an assets(picture, video) using the &lt;code&gt;nft_mint&lt;/code&gt; method from the contract.&lt;/p&gt;

&lt;p&gt;Create  file names &lt;code&gt;config.js&lt;/code&gt;, &lt;code&gt;Modal.js&lt;/code&gt;, &lt;code&gt;useModal.js&lt;/code&gt; &lt;code&gt;Close.js&lt;/code&gt; and &lt;code&gt;App.css&lt;/code&gt; in your &lt;code&gt;nft-marketplace-part-1/src&lt;/code&gt; directory with the following code:&lt;/p&gt;
&lt;h4&gt;
  
  
  config.js
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h4&gt;
  
  
  useModal.js
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h4&gt;
  
  
  Modal.js
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h4&gt;
  
  
  Close.js
&lt;/h4&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  App.css
&lt;/h3&gt;

&lt;p&gt;For  this file you can find the CSS code &lt;a href="https://github.com/kels-orien/nft-marketplace-part-1/blob/main/src/App.css" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To run React app from CLI:&lt;br&gt;
From &lt;code&gt;nft-marketplace-part-1&lt;/code&gt; directory, use command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>web3</category>
      <category>javascript</category>
      <category>react</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
