Code examples for the blog post titled The Complete Guide to Full Stack Solana Development with React, Anchor, Rust, and Phantom

Overview

The Complete Guide to Full Stack Solana Development with React, Anchor, Rust, and Phantom

Code examples to go with the blog post available here

Header image

Prerequisites

  1. Node.js - I recommend installing Node using either nvm or fnm

  2. Solana Tool Suite - You can see the installation instructions here. note - I had a very hard time getting everything working on an M1 Mac, mainly solana-test-validator and cargo-build-bpf. I finally figured it out, and posted my solution here. I'm sure at some point this will be fixed and work out of the box.

  3. Anchor - Anchor installation was pretty straight-forward for me. You can find the installation instructions here.

  4. Solana browser wallet - I recommend Phantom, which is what I have tested this app with.

To build

  1. Clone the repo
git clone [email protected]:dabit3/complete-guide-to-full-stack-solana.git
  1. Change into the project directory you'd like to run

  2. Install the dependencies

npm install
  1. Start a local Solana node
solana-test-validator
  1. Build the anchor project
anchor build
  1. Fetch the project ID for the build:
solana address -k target/deploy/<programname>-keypair.json
  1. Update the project ID in the Rust program located at projectname/programs/src/programname.rs with the output from above.

  2. Run the tests

anchor test
  1. Change into the app directory and install the dependencies:
cd app && npm install
  1. Run the client-side app
npm start
You might also like...
Facebook components like a Login button, Like, Share, Chat, Comments, Page or Embedded Post

React Facebook Components Components Facebook provider (provide settings to child components) Login button (provide user profile and signed request) L

Full-Stack Project that shows the weather forecast
Full-Stack Project that shows the weather forecast

Projeto Previsão de chuva Projeto que mostra a previsão de tempo de cada bairro Tecnologias Pre Requisitos Como usar Pasta front-end Pasta back-end Av

ReactJS-Spring-Boot-CRUD-Full-Stack-App - Course on YouTube

ReactJS-Spring-Boot-CRUD-Full-Stack-App - Course on YouTube

⛵️ A React library for Solana account management and transaction processing.

sail ⛵️ A React library for Solana account management and transaction handling. Usage import { SailProvider } from "@saberhq/sail";

A web application that allows you to create and share wall of gifs! Built on top of solana blockchain.

Wall of gif with Solana A web application that allows you to create and share wall of gifs! Built on top of solana blockchain. Installation and Usage

Auth Service sample source. It supports Solana and EVM-compatiable chains

This repository is Auth Service sample source. It supports Solana and EVM-compatiable chains, more chains and more features coming soon! Learn more visit Particle Network.

_buildspace - web3 Read/Write Solana Blockchain Project
_buildspace - web3 Read/Write Solana Blockchain Project

_buildspace - web3 Read/Write Solana Blockchain Project

Solana Wallet Auth: A FullStack example
Solana Wallet Auth: A FullStack example

This example uses Solana's wallet adapter to sign messages and verifies their signatures on the backend, allowing for a lean way to authenticate users without the need for web2 credentials like email/password combinations or social providers, in this scenario all you have to do is connect your wallet and sign interaction messages to be properly authenticated.

Step-by-step guide on compiling C++ codes with Emscripten into wasm and using it with Webpack + Typescript + React setup
Step-by-step guide on compiling C++ codes with Emscripten into wasm and using it with Webpack + Typescript + React setup

Step-by-step guide on compiling C++ codes with Emscripten into wasm and using it with Webpack + Typescript + React setup

Comments
  • Refactor: update example1

    Refactor: update example1

    Hi @dabit3,

    Thank you very much for creating The Complete Guide to Full Stack Solana Development with React, Anchor, Rust, and Phantom and this project. Very helpful and resourceful guide and project for sure.

    In the process of looking into this project, I wanted to improve the project e.g.:

    • TypeScript based create-react-app
    • The latest create-react-app version with webpack 5 and React 18
    • Project set-up approaches introduced in @solana/wallet-adapter and @solana/wallet-adapter-example
    • etc (Above are just what I can remember right now since I've updated a lot :))

    I think some/many potential and current issues have been resolved via this PR (let me explain in detail down the line).

    For the changes included in this PR, let me add the context in detail so that you can review them easily. Thank you.

    opened by anton-karlovskiy 0
  • Transaction simulation failed: Attempt to load a program that does not exist

    Transaction simulation failed: Attempt to load a program that does not exist

    Following this tutorial

    I have followed all of the steps up to the point of building the counter code, including having a running localhost validator.

    I have taken the output of solana address -k target/deploy/mysolanaapp-keypair.json

    and input it in lib.rs and anchor.toml as instructed, and get the following after running anchor build and then anchor test:

    mysolanaapp
    Transaction simulation failed: Attempt to load a program that does not exist
    
    
    opened by heaversm 0
  • TypeError: program.rpc.startStuffOff is not a function

    TypeError: program.rpc.startStuffOff is not a function

    Hi, i'm facing this error can you please help me?

    i'm running test using anchor test

    anchor.setProvider(anchor.Provider.env()); const program = anchor.workspace.Myepicproject; const tx = await program.rpc.startStuffOff(); // error is here

    opened by shahzaibanwar009 0
  • Error: Invalid hook call

    Error: Invalid hook call

    Hi,

    When trying to run the frontend from any of the examples. I get greeted with the following error:

    Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
    1. You might have mismatching versions of React and the renderer (such as React DOM)
    2. You might be breaking the Rules of Hooks
    3. You might have more than one copy of React in the same app
    See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    

    I googled around and apparently it can happen if different version of react are used. In my case I only see one version, eventhough it's regerenced more than once but it's getting 'deduped':

    ├─┬ @solana/[email protected]
    │ ├─┬ [email protected]
    │ │ └── [email protected] deduped
    │ └── [email protected]
    └─┬ @solana/[email protected]
      └── [email protected] deduped
    

    To reproduce simply npm install in the app folder, then run npm start

    opened by misterch0c 2
Owner
Nader Dabit
Specializing in React, cloud, cross-platform, and full stack blockchain application development.
Nader Dabit
This is a proof of concept of an NFT vending machine built using Solana Pay, Metaplex, Phantom Mobile, and Next.js

Solana NFT Vending Machine This is a proof of concept of an NFT vending machine built using Solana Pay, Metaplex, Phantom Mobile, and Next.js. This wa

Matt Rosenzweig 55 Dec 15, 2022
A simple Solana program to vote for your favorite type of peanut butter. Built with Anchor and React.

Cruchy vs Smooth V2 A simple Solana program to vote for your favorite type of peanut butter. Built with Anchor and React. This is a follow up to a pre

Brian Friel 45 Oct 12, 2022
Gif Portal build using solana, anchor, web3 and react

Features of the dapp View Popular Dance Moves Gifs Vote for your favorite Gifs Add link of your favorite dance gif on the portal All the data includin

Anshul Goel 5 Oct 27, 2022
A Remix stack setup to run on Deno with support for Rust WASM modules!

Remix + Deno + Rust -> Webassembly - The Air Metal Stack Welcome to the Air Metal Stack for Remix! ?? + ?? This stack is a good choice if you want to

Ben Wishovich 59 Dec 13, 2022
A guide to building your own React stack, explaining options and tradeoffs along the way

Custom React Stack React has a very rich ecosystem. For anything you want to do, there is probably a library or a framework available for it. That's g

Naresh Bhatia 13 Nov 23, 2022
Share code between different parts of your full-stack app

Dryduck Every programmer knows dry. Don't repeat yourself. So why repeat yourself across platforms, writing the same thing twice? Dryduck is a tool fo

Code From Anywhere 2 Dec 18, 2021
Super simple react-anchor tutorial

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: ya

null 21 Dec 13, 2022
Kai Tinkess 2 Jan 23, 2022
React Query and Axios example with CRUD operation - GET/POST/PUT/DELETE request with Rest API

React Query Axios example with Rest API React Client with React Query and Axios to make CRUD requests to Rest API in that: React Query Axios GET reque

null 16 Nov 7, 2022