August 14, 2023

Lightweight boilerplate for Solana dapps. Allows quick building and prototyping

Solana Boilerplate

Lightweight boilerplate for Solana dapps. Allows quick building and prototyping.

⭐️ Star us

If this repo helps you building your dapps on Solana - please ensure you leave us a star! This motivates and helps us a lot to bring more free code, templates and boilerplates to you.

🤝 Need help?

If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this boilerplate is the super active community ready to help at any time! We help each other.

🚀 Quick Start

📄 Clone or fork solana-boilerplate:

git clone https://github.com/solana-boilerplate/solana-boilerplate.git

💿 Install all dependencies:

cd solana-boilerplate
yarn install 

✏ Rename .env.example to .env in the main folder and provide your appId and serverUrl from Moralis (How to start Moralis Server) Example:

REACT_APP_MORALIS_APPLICATION_ID=xxxxxxxxxxxx
REACT_APP_MORALIS_SERVER_URL=https://xxxxxx.grandmoralis.com:2053/server

🚴‍♂️ Run your App:

yarn start

🧭 Table of contents

🏗 Solana Components

🧰 Solana Hooks

useSolana

Gets basic Solana information such as user's address.

Example

const { account } = useSolana();

useSolanaNativeTokenBalance

Gets Solana SOL token balance of an address.

Example

const { getSolanaNativeBalance, data, error, isLoading } = useSolanaNativeTokenBalance({
  network: "mainnet",
  address: "xxx"
});

useSPLTokenBalance

Gets Solana SPL token balance of an address.

Example

const { getSPLTokenBalance, data, error, isLoading } = useSPLTokenBalance({
  network: "mainnet",
  address: "xxx"
});

useSPLNFTBalance

Gets Solana NFT balance of an address.

Example

const { getSPLNFTBalance, data, error, isLoading } = useSPLNFTBalance({
  network: "mainnet",
  address: "xxx"
});

useSolanaPortfolio

Gets Solana portfolio (SOL, SPL token, SPL NFT) of an address.

Example

const { getSolanaPortfolio, data, error, isLoading } = useSolanaPortfolio({
  network: "mainnet",
  address: "xxx"
});