How to build dApp on Solana in 8 simple steps?

solana dapp development

About Solana

Solana is an open-source public blockchain network utilized to run programs, also known as Smart Contracts. This blockchain network was developed to facilitate scalability and low transaction cost, especially for growing businesses.

Solana claims to be the world’s fastest blockchain with 50K to 65K Transactions per second with 429-millisecond block finality. Moreover, the average transaction cost of $0.00025 has been attracting developers to explore this platform.

It employs the Proof-of-Stake and Proof-of History protocols to solve the scalability constraint without compromising on decentralization and security of the network.

What is the Solana Ecosystem?

The Solana ecosystem is a cluster of technologies that work in tandem with the protocol to enhance its speed and scalability. The ecosystem also comprises a dApps collection built on Solana’s open-source network.

Step by Step guide on how to build dApp on Solana Blockchain

Step 1 – Install all the required applications for the project

This will include the Installation of Rust, Solana, node.js, Yarn, and Anchor

First, you need to start with the installation of the programming language, Rust. It is used to write smart contracts on Solana. 

Use the following command:

curl — proto ‘=https’ — tlsv1.2 -sSf https://sh.rustup.rs | sh

For those who want to do it on windows, they can install any of the code hosting services that let developers build software for open source and private projects in organizations such as BitBucket, Amazon Web Services, Github, Gitlab, CircleCI, etc. 


Once the programming language is installed, add the Rust executables by running the following command:

export PATH="$HOME/.cargo/bin:$PATH"

Check the installation through the following commands:

rustup --version
rustc --version
cargo --version

Now install Solana. You can use this command for the action:

sh -c "$(curl -sSfL https://release.solana.com/v1.9.8/install)"

Check the installation by running the command:

solana --version

Now, install node.js and Yarn as they are important to work with the Anchor programs. You can install the LTS version from Node.js.

Check the installation through the following command:

node --version
npm --version

Then install the yarn by running the following command:

npm i -g yarn

Next comes the Anchor installation. It is a protocol that facilitates building programs on Solana. Run the following command:

cargo install --git GitHub - project-serum/anchor: ⚓ Solana Sealevel Framework  anchor-cli --locked

Again, confirm the installation with:

anchor --version
cargo install --git GitHub - project-serum/anchor: ⚓ Solana Sealevel Framework  anchor-cli --locked

Once again, confirm the installation through the command:

anchor --version

Step 2 – Format the Project

By default, Solana is configured to operate on the mainnet. This means that each transaction contains a unique SOL coin as a gas fee. Hence you do not need to repeat the same while creating dapps.

Here you have to start with Configuring Solana CLI Utility to tap into devnet and Initialize the project with the Anchor framework. Further, You have to set up Solana and the devnet to work together by using the command:

solana config set --url devnet

Now, you will need to run and deploy your programs with your wallet. For that run the following command:

solana-keygen new --force

Confirm the wallet’s address:

solana address

Use test Solana coins through the airdrop command

To check the account balance, run the command:

solana balance

Lastly, setup the Anchor framework by running the given command:

anchor init solana-global-article
cd solana-global-article

Step 3 – Start coding in the Rust

Use your code editor to access the global article project

Go to Programs > src > Lib.rs — home to Rust crates

Open the file and prepare a note of Lib.rs — home for Rust crates and the main file for the Solana program

After that, build data structures to store the content. Add the Article struct by running the following command:

#[account]pub struct Article { pub content: String,}

Then continue to create the Initialize struct by running the following command:
#[derive(Accounts)]
pub struct Initialize<'info> {
 #[account(
 init,
 payer = person_that_pays,
 space = 8 // account discriminator
 + 32 // pubkey
 + 10000 // make the message max 10k bytes long
 )]
 pub article: Account<'info, Article>,
 #[account(mut)]
 pub person_that_pays: Signer<'info>,
 pub system_program: Program<'info, System>,
}

Then, go to the #program section and develop the main function through the given command:

#[program]
pub mod solana_global_article {
    use super::*;
    pub fn initialize(ctx: Context<initialize>) -> ProgramResult {
        // Get the article
        let article_account = &mut ctx.accounts.article;
        // Initialize the variables (this is required)
        article_account.content = ("").to_string(); Ok(())
    }
}
</initialize>

Your Solana program is ready for dApp development

Step 4 – Solana Anchor Updation

Go to  programs/mysolanaapp/src/lib.rs and update it through the following code:

use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
mod mysolanaapp {
    use super::*;
    pub fn create(ctx: Context<create>) -> ProgramResult {
        let base_account = &mut ctx.accounts.base_account;
        base_account.count = 0;
        Ok(())
    }
    pub fn increment(ctx: Context<increment>) -> ProgramResult {
        let base_account = &mut ctx.accounts.base_account;
        base_account.count += 1;
        Ok(())
    }
}
// Transaction instructions
#[derive(Accounts)]
pub struct Create<'info> {
    #[account(init, payer = user, space = 16 + 16)]
    pub base_account: Account<'info, BaseAccount>,
    #[account(mut)]
    pub user: Signer<'info>,
    pub system_program: Program <'info, System>,
}
// Transaction instructions
#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut)]
    pub base_account: Account<'info, BaseAccount>,
}
// An account that goes inside a transaction instruction
#[account]
pub struct BaseAccount {
    pub count: u64,
</increment></create>

Step 5 – React app creation

Create a new application by overwriting the existing application directory at the base of the Anchor project. Utilize the command below:

npx create-react-app app

After that, run the following command to install the dependencies required for Anchor and Solana Web3:

cd app
npm install @project-serum/anchor @solana/web3.js

Step 6 – Wallet Adapter Installation

Manage your Solana wallet by installing the Solana wallet adapter by running the following command:

npm install @solana/wallet-adapter-react \
@solana/wallet-adapter-react-ui @solana/wallet-adapter-wallets \
@solana/wallet-adapter-base

Create a new file idl.json. in the src directory. Herein, copy the IDL JSON built in the main project folder.

Step 7- Choose a wallet network

It is important to host your wallet on a sound network before you start interacting with a program on the localhost network. For this, reach out to the Settings option in your wallet, go to change network, and select the localhost. 

After that, airdrop some tokens into this wallet. Select the address at the top of your wallet and copy it and paste it to the clipboard.

Now, open the terminal and execute the following command:

solana airdrop 10

This will result in airdropping the required amount of tokens to run and test the dApp.

Once the tokens are received, switch to the app directory and run the following command:

npm start

Step 8 – Deployment of DApp

Copy the new IDL to the frontend to deploy your dApp. Run the below command for the procedure:

anchor run copy-idl

Now, run the given command to serve the frontend application locally:

npm run serve

To deploy the dApp, switch to the cluster of devnet using the command:

solana config set --url devnet
and update the Anchor.toml file.

Lastly, deploy it on the mainnet through the command:

anchor deploy

Essentials required prior to building a dApp on Solana

Programming Experience

It goes without saying that to develop an app right from from start, some form of programming experience is certainly required. Rust, C, and C++ are the programming languages of Solana.  While C and C++ are one of the most basic and widely-known languages, Rust is comparatively new. However, unlike one common misconception, one does not need to have vast experience and deep knowledge to start working on Rust. 

In fact, a person with decent programming knowledge will be able to easily understand its functions and make their way through. All that is needed is to undergo some form of tutorial before going into a full-on programming mode.

Expertise in blockchain

Well, this goes without saying. While immutability is a big advantage for the safety of the data on the blockchain, one small mistake can result in a bugged dApp getting deployed with no probability of change whatsoever. Hence having deep knowledge of blockchain does form an important prerequisite.

JavaScript for Frontend

The interaction of the client with the Solana program is facilitated by the frontend framework Vue 3 Single-Page Application (SPA) on JavaScript. Hence,  a little knowledge of working on JavaScript will give the dApp a great look and interactivity. It will enhance the users’ experience and enlarge the user base.

Why is Solana better for businesses?

As we saw in the above section, one does not need a lot of experience before starting the development on the Solana platform. Thanks to it being a user-friendly and easy-to-program set of features. Moreover, Solana comprises a variety of off-the-shelf tools stashed in the Solana ecosystem that even new users will find handy.

For businesses, Solana offers transformative qualities by offering a unique and robust dApps development experience. It opens the prospects of a high-scale business through high speed, scalability served with low transactional cost. Here are some of the most notable features of Solana.

Speed for scalability

Solan can process 710,000 transactions of size equal to or less than 176 bytes per second for a centralized database on a standard gigabit network. It is the fastest blockchain network with 400 millisecond block time. The high speed contributes to the easy scalability of businesses.

Low Transactional Cost

The next important benefit of Solana for business is the low-cost gas fee charged per transaction. It is the fee that users need to pay in order to utilize the Solana platform for transactions. A single transaction on Solana cost around $0.00025, which is a fraction of what is charged on other competitive blockchains.

Easy programming

Solana is a user-friendly open-source blockchain network. What it means is that users and developers can download readymade codes directly from Solana Lab and use them to create new and well-functioning products. This is what is attracting dApp developers from across the globe to the platform searching for easier and faster programming.

No blockage

Since Solana exudes high speed, there is no issue of transactions getting stuck in mempool. Mempool is a location where the processed transactions have to wait to get accepted as a block on the chain. At the Solana platform, transactions are directly added to the blockchain saving a lot of time and minimizing the network congestion. Hence, no such issue of Mempool blockage exists in this blockchain platform.

Benefits of Rust

Solana inherits the benefits of programming in Rust such as memory safety and thread concurrency. This is because most of the dApps in the Solana ecosystem are developed in Rust programming language.

What makes Solana dApps distinct from others?

Gulf Stream

Solana dApps functions on the Gulf Stream mechanism which minimizes the total number of transactions in the mempool sections. It helps in reducing delays and results in negligible mempool status. 

Under this mechanism, Solana pushes the transactions caching and forwarding to the periphery of the network. It allows the validators to process transactions instantly to reduce the overall dApp functioning duration.

Sealevel

Sealevel is another distinguishing feature of Solana dApps that enhances their processing speed. It is a mechanism that involves simultaneous functioning of Solana Programs or Smart Contracts. It also revs the validation process of dApps carried out by the smart contracts.

Proof-of-History

Solana dApps utilize the Proof-of-History(P-o-H) consensus mechanism. It is a high-frequency Verifiable Delay Function (VDF) that lets nodes generate blocks in continuance and establish a reliable and secured time source across the network.

The function requires a specific number of sequential steps for evaluation and produces a unique output every time. This output can be publicly verified.

Hence, it does away with the need to trust timestamps on messages received from the other nodes on a distributed network.

Pipeline

The pipeline is a Transaction Processing Unit (TPU) for validation on the Solana blockchain. It is used to process a stream of input data through a sequence of steps with each requiring different hardware. 

The data is packed together into a bunch in order to undergo different processes one after another. 

TPU is an upgraded CPU design where validation occurs instantly between various nodes. 

It improves speed and saves resources.

Turbine

One of the challenges that affect high-performing blockchains is the propagation of large amounts of data to a large number of peers. 

Solana solves this issue through the Turbine block propagation protocol. Under the system, the cluster is divided into what is called neighborhoods, a small collection of nodes. Within the neighborhood, each node is responsible to share all the received data with the other nodes. Moreover, they also make sure to propagate data onto a small set of nodes in other neighborhoods. Hence, each node has to communicate with a small number of nodes only. This expedites the process and results in a speed that Solana is known for.

Myths About Solana Development

You need experience with Smart Contract or Rust before starting development on Solana

This is a myth. In fact, one doesn’t need a lot of experience in Rust programming. There are a lot of programs available on the Solana ecosystem for users to build with. They can build dApps just like the way web applications are developed on web 2 through a centralized application. However, on Solana, dApps are stored on a decentralized blockchain rather than on a centralized database and the transaction/storage cost is paid for by the users instead of the developer. 

SOL rewards are not backed and are created out of thin air

As of now, there are around 350+ projects built and running on the Solana blockchain. Each transaction executed within any of these projects costs SOL. This brings an intrinsic value to the native currency, SOL. Hence, even if everyone suddenly loses trust in SOL, its value would only drop slightly as there is a direct utility of the currency.

Solana is not decentralized

Another myth that has been floating around was that of Solana not being decentralized and the network can be shut down anytime. This myth originated under the pretext that the network was shut down on 14th September 2021. 

However, the story was different as the number of transactions exceeded 400,000 TPS due to bot activity during an IDO. This led to the network starting to crack under pressure. Hence, around  80% of validators coordinated together to shut down and restart the network. 

The decision was not made solely by the Solana foundation as they don’t have the authority for the same. This shows the decentralized nature of the Solana network.

Solana Development Services by Queppelin

Queppelin is known to be one of the leading companies that specialize in offering exhaustive Solana Blockchain Development Solutions. Solana brings with it a range of benefits and features discussed above such as high transaction speed, low cost, faster data transfer, better processing mechanism, etc. These qualities make Solana the best platform to meet business goals and Queppelin helps your reap these benefits with its best-in-class services.

Solana Blockchain Consulting

We offer comprehensive consultation for the smooth and seamless integration of Solana into the existing systems. Allowing your business you can avail the outstanding benefits of this fast, secure, and low-cost platform.

DApps Development on Solana

We assist in launching scalable, high-speed, fully customized, and user-friendly dApps on the Solana platform. Here, we offer a range of services like Payments, NFT marketplaces, Token swaps, Stable coins, etc.

Smart Contract Development 

Smart contracts or programs help you automate your business and improve its efficiency.  We assist your efforts with our Solana-based Smart contract development services. The technology facilitates contract execution at lightning speed without involving any third party.

Solana Defi Development

We offer a range of Solana-based Defi Development Services. These systems allow you to connect with borrowers and lenders from all over the globe and tap the enormous potential in the Defi market.

Solana Wallet Development Services

We help you build fast, easy-to-use, and secure, web and mobile wallets for your Solana projects. We ensure better payment integration solutions through wallets complying with the required regulations.

Solana Token Development

Tokenization is yet another area of our expertise. We can tokenize real-world assets as well as edit the existing tokens. Further, these tokens are suitable to be traded on Decentralized Exchanges or DEX and can be used for investment, and management of dApps.

Solana NFT Marketplace

Solana is a perfect platform for NFT marketplace development due to its high transaction speed and lower cost. This results in maximizing the number of transactions in a given time and facilitates high scalability of the Solana blockchain to shoot up your sales.

Node Development on Solana 

Our Node Development services on the Solana Blockchain network open new streams of income for you. Become a validator and contribute to the security of the Solana network by connecting to the mainnet and earning SOLs.

Solana Exchange Integration

We assist in a seamless exchange integration that facilitates swaps across blockchains, receives orders, and reduces disputes. We utilize the unique protocol based on Solana i.e. Serum.

Terminology you should know

account

A record to hold data in a Solana ledger. It can also be an executable program

app

It is a front-end application that can interact with a Solana cluster.

bank state

It is an outcome of the interpretation of all programs on the ledger at a given tick height. It includes a minimum of the set of all accounts holding nonzero native tokens.

block

A contiguous set of entries on the ledger is covered by a vote. A leader produces at most one block per slot.

blockhash

A unique value to identify a record (block). Solana calculates the blockhash from the last entry of the block.

block height

The number of blocks beneath the current block. The first block after the genesis block has height one.

bootstrap validator

The validator produces the genesis block or the first block of a blockchain.

BPF loader

A Solana program that owns and loads BPF smart contract programs, allowing the program to interact with the runtime.

client

The computer program that accesses the Solana cluster.

cluster

A set of validators that maintain a single ledger.

confirmation time

The duration between a leader creating a tick entry and creating a confirmed block.

confirmed block

A block achieving the supermajority of ledger votes.

control plane

A communication network to connect all nodes of a cluster.

cooldown period

It is the number of epochs after stake deactivation that becomes available for withdrawal. During this period, the stake is considered to be “deactivating”. 

credit

Same as vote credit.

cross-program invocation (CPI)

A call from one smart contract program to another. For more information, see calling between programs.

data plane

It is a multicast network that is used to efficiently validate entries and achieve consensus.

drone

A custodian off-chain service for a user’s private key. It generally serves to sign and transaction validation.

entry

An entry on the ledger can either be a tick or a transaction.

entry id

A globally unique identifier which is a preimage resistant hash over the final contents of an entry.

epoch

The time for which a leader schedule is valid.

fee account

It is the account that pays for the cost of including the first transaction in a ledger. 

finality

When nodes representing 2/3rd of the stake have a common root.

fork

A ledger derived from common entries but then diverged.

genesis block

The first block in the chain.

genesis config

The configuration file that prepares the ledger for the genesis block.

hash

A digital fingerprint of a sequence of bytes.

inflation

An increase in token supply over time used to fund rewards for validation and to fund continued development of Solana.

inner instruction

See cross-program invocation.

Subscribe to our newsletter to receive news on Metaverse, Blockchain, AR, VR and more.

Newsletter