With a rise in the climate change crisis, there is a subsequent increase in demand for eco-friendly blockchain networks. Regarding this, several blockchain networks play a huge role in sustainable carbon emissions in today’s environment. Minting and trading NFTs on a blockchain network consumes much power, emitting approximately 100 kgCO2 footprints. This amount is equivalent to the number of carbon footprints cast by a one-hour flight. NEAR, therefore, has one of the most sustainable ecosystems for minting and trading NFTs. This article is a step-by-step guide to building an NFT marketplace on NEAR.
To successfully address the concern of carbon footprints emitted from NFT or block minting, NEAR Protocol’s computational mechanism is based on Proof-of-Stake (PoS) consensus. There are no miners in the PoS consensus mechanism; the validators have the authority to stake a given token amount for their participation in the voting mechanism. Proof-of-Stake consensus mechanism thus helps blockchain communities to validate blocks and gather block awards.
NEAR’s Proof-of-Stake consensus is known as the Nightshade. Other than Nightshade, Sharding is another mechanism that helps the network attain scalability and security in an ecological and carbon-neutral way. Nightshade and sharding function simultaneously to allow every transaction to be energy efficient by splitting the network’s data computational load. This results in a final reduction of energy consumption, thus producing a minimum amount of carbon footprints.
About NEAR blockchain
NEAR is a decentralized and carbon-neutral blockchain platform based on sharding and Nightstand mechanisms. It is a smart contract-capable blockchain protocol crafted to ensure the development of highly scalable dApps. NEAR blockchain has the efficiency of processing approximately 100,000 transactions per second. It has a community-operated cloud infrastructure for deploying and running the dApps on the network.
NEAR combines the distributed database features with a server-less database computing platform. NEAR token powers the NEAR dApps to connect with each other in different ways. NEAR blockchain helps the developers to build censorship-free backends for smart contract functioning to manage high-stake data like digital assets, identities and money.
NEAR blockchain functions in a similar way to a centralized data storage ecosystem. For example, Amazon Web Services (AWS) functions as a base layer on which the applications are built. The main difference between AWS and the NEAR platform is that- NEAR is a decentralized network of computers and is not controlled by a single authority. It allows the development of the dApp & NFT marketplace architecture around the network.
Some of the fundamental components of the NEAR platform are as the following:
- NEAR Token
- NFT Minting Platform
- Flux Protocol
Let us now look at some of the benefits of developing on the NEAR blockchain in the next section.
What are the benefits of building on NEAR?
NEAR blockchain has a progressive User Experience (UX) for its dApp users in DeFi. Based on the sharding mechanism, NEAR Protocol helps network data retrieval and scales the dApps on DeFi platforms.
Along with sharding, it also uses a PoS election mechanism known as the Threshold Proof-of-Stake (TPoS). This mechanism paves a predetermined way for creating many participants to manage the blockchain network. TPoS helps increase the level of decentralization and security of the blockchain network. NEAR Protocol uses TPoS to create a reward distribution system for dApp users.
Let us now explore the benefits that make NEAR Protocol a fit for blockchain-based application development:
NEAR Protocol has an efficient PoS network that ensures network sustainability and carbon neutrality. This powers the users to run various dApps and process blockchain transactions efficiently.
NEAR Protocol has 1000 times lower transaction fees for its users and developers, comparatively less than most third-generation blockchains. It charges 30 percent of the transaction fees for participating in the network’s growth.
NEAR Protocol can produce a human-readable account address based on scoped DNS pattern. With the human-readable address, NEAR becomes a user-friendly blockchain that lets people with zero technical knowledge access the network.
With a robust network of active validators, NEAR maintains its credibility and high security throughout the network.
NEAR components like the EVM and cross-chain Rainbow bridge support NEAR to facilitate cross-chain transactions and exchanges among various independent blockchain platforms.
NEAR smart contracts are written in expressive community-supported coding languages: Rust and AssemblyScript.
Now that we are familiar with the benefits let us look at the development suite of NEAR in the next section.
What are the essential development components of NEAR?
NEAR blockchain is built to be used independently in a permissionless way but with a set of tools and implementations. NEAR development suite consists of the following components:
Gitpod for NEAR
NEAR uses the existing Gitpod technology to provide a zero-time onboarding experience to the developers. This technology has an online ‘Integrated Development Environment (IDE). Using the IDE, developers can efficiently write, test and deploy NEAR smart contracts from the browser.
NEAR also has other templates that can be deployed with one click, making the development process easy for new and old developers.
NEAR wallet has built-in functionality to help, holders participate in the staking and governance processes on the NEAR platform. It powers the developers and end-users to store the digital assets on the NEAR network.
NEAR’s explorer helps the users understand the NEAR network’s performance and facilitates debugging of the contracts. It provides real-time network data in an easily understandable web-based graphical format.
NEAR command-line tools
NEAR owns command-line tools that allow developers to create, test, and deploy applications from their local environments.
In the next section, let us now understand the step-by-step process of developing an NFT marketplace on the NEAR platform.
How to build an NFT marketplace on NEAR?
- The NEAR wallet account is a secure and wallet manager for NEAR users’ accounts. A NEAR wallet account will allow users to connect with various decentralized applications on NEAR. It also stores the NEAR tokens and NFTs securely. This section will use a testnet wallet to develop an NFT marketplace on NEAR.
- Rust Toolchain is a specific version of a group of programs required to compile a Rust application.
- NEAR-CLI is a NodeJS CLI that uses the near-API-js to interact and connect with the NEAR network.
The NEAR NFT marketplace development is divided into two parts:
- Part 1- Setting up the NFT contract
- Part 2- Setting up the marketplace
To set up smart contracts for the NEAR NFT marketplace, follow these steps:
Clone the intelligent contract development application by using the command line interface:
Open the wallet testnet account from the nft-contract folder by using the command CLI and then log in to the NEAR wallet account by inserting the following code:
Then build the contract from the nft-contract directory by using the CLI; there are two different CLIs as given below:
For the Windows user:
For the Mac and Linux users:
Use the following CLI to create a sub-account from the nft-contract directory:
Deploy the smart contract using the following command:
Then edit the contract name by changing the youraccountName section of the contractName component in the config.js file to a preferred ant name.
Then install all the packages for the frontend; go to the root of the directory nft-marketplace-part-1 by using the CLI given below:
Lastly, launch the frontend by running the below mentioned CLI:
Begin the NEAR NFT marketplace development with a rust contract template. Create a directory named nft-marketplace-part-1 from the CLI. Then, enter the project root directory as:
After this, clone the following rust template in the nft-marketplace-part-1 root directory:
The alter and rename the rust-template file to nft-contract. Then, update the Cargo.toml file by entering the following command:
Modify the name, run the build script and change the compiled wasm file’s name.
Windows users will use build.bat and the Linux users will use build.sh. Now copy the src directory of the nft-contract file in the new nft-contract folder. It should look like this:
- approval .rs has the functions to control the access and transactions of NFTs
- enumeration.rs lists the NFT tokens and their respective owners.
- Lib.rs stores all the smart contract initialization functions.
- metadata.rs explains the metadata structure and the token.
- mint.rs explains the token minting logic
- nft_core.rs contains the core logic that allows the NEAR users to transfer NFTs.
- royalty.rs has the functions related to the payout on the NFT marketplace.
Login to the NEAR account
Login to the near account from the CLI:
This will open the NEAR wallet, in which the user will confirm the creation of a full-access key. then follow the instructions from the login CLI to create a key on the user hard drive. This key will be stored in the users’ operating system’s home directory in a near-credentials file.
Build the contract
Build the contract from the nft-contract directory through the CLI:
For Windows users:
For Linux and Mac users:
Create a subaccount and then deploy the smart contract to this subaccount by using the following CLI:
Deploy the contract
Use the following CLI to deploy the contract:
Initialize the contract
Initialize the contract from CLI,
For Mac and Linux users:
For the Windows users:
After initializing, see the metadata through the CLI by using the following command:
Mint NEAR NFT tokens using the following commands,
For Windows users:
For Mac and Linux users:
Check all the collectibles section of the testnet wallet for the recently minted NFTs.
View NFT data via CLI
For Mac and Linux users:
For Windows users:
To transfer the NFTs, create another testnet wallet account and transfer the NFT by running the command through CLI:
Add the react with the parcel-bundler on the nft-marketplace-part-1/src directory. Then create an src folder in the nft-marketplace-part-1 and shift the index.html and intex.js in the same folder.
Then, update the script sections of the package.json by running the following command:
Update the src/index.js folder with the following code:
Then the initContract method is called, and all the data is passed to the App.js Component using the following codes:
Create all the file names config.js, Modal.js, useModal.js Close.js and App.css in the nft-marketplace-part-1/src directory using the following code:
Lastly, run the React application from the CLI from nft-marketplace-part-1 using the following command:
Now that we are familiar with NFT marketplace development on NEAR let us look at its development services provided by Omatech in the next section.
What NEAR development services does Omatech provide?
Leveraging the advantage of infinite scalability provided by Near Protocol, we build advanced, secure, and scalable dApps on the Near protocol. We also analyze your project’s technical aspects to accentuate your dApp’s utility.
Our blockchain experts analyze and innovate feature-rich NFT marketplaces on Near Protocol, providing you with the most curated NFT trading platform. With the intrinsic features of Near blockchain, we tailor your marketplace precisely to best suit your business use case.
We provide smart contract development services to regulate your business processes on Near protocol. We cover every angle of contract development, from smart contract architecture to design, auditing, and optimization.
We help enterprises leverage interoperability with cross-chain bridge launch on the Near Protocol, permitting their users to seamlessly exchange tokens, arbitrary data and resources across multiple independent blockchains.
Node and wallets
We help you develop and run a node on Near Protocol based on your project-specific requirements. Our developers build and integrate wallets into your dApp and decentralized exchange to support dApps and associated transactions.
We provide DAO creation and integration services, keeping various aspects of your project in focus. DAO helps you build trust among the users by permitting them to propose changes to the protocol and take major decisions.
Maintenance & upgrade
We also offer our clients consistent support and maintenance services to ensure their dApps are optimized and running with negligible downtime.
NEAR blockchain is one of the distinctive blockchains with an environment-friendly and carbon-neutral protocol that emits minimal carbon footprints. It is a highly scalable network based on the Nightshade and sharding consensus mechanisms.
Along with scalability, it has unique features like interoperability and human-readable account names instead of cryptographically-coded wallet addresses to its credibility. This makes it easier for the users to access the wallets and dApps. NEAR blockchain is; thus, one of the most compatible blockchains meeting the dApp development needs of various businesses and startups.
Contact our blockchain experts for further in-depth guide if you want to develop an NFT marketplace for your businesses on the NEAR protocol.