- create solana DAPP
- use PDA (Program Driven Address)
- transfer funds from one account to other using onchain Rust code by CPI
- create React App (in app folder)
- phantom wallet intigration in react
cd my-solana-wallet
solana-keygen grind --starts-with cf:1
solana config set --url devnet
solana airdrop 2 -k [wallet.json]
run yarn install
in root directory
set newly generated wallet address in "Anchor.toml" file
run cargo clean
, anchor build
and solana address -k target/deploy/solana_crowdfunding_dapp-keypair.json
copy new program id and past it in "Anchor.toml" and "lib.rs" files
run anchor build && anchor deploy
copy target/idl/[program name].json
file data and past it in app/src/idl.json
run cd app
run npm install
run npm start
- Initialize: This struct use for create and initialize the PDA. Whenver we create a new compaign that program will first create the PDA for thet compaign and that PDA will hold the program data and balance that any one will donate.
- Withdraw This struct use for the withdraw balance from PDA and only admin who will create the compaign can withdraw the SOL.
- Donate This struct use when a doner wants to donate an ammount of SOL and tha PDA will hold that SOL.
- Compaign This is the basics struct that use in above all structs.
- initialize(ctx: Context, name: String, description: String) -> Result<()> Use for create and initialize new compaign. This function gat the 3 perameters 1: Initialize struct, 2: name String and description String.
- withdraw(ctx: Context, amount: u64) -> ProgramResult Use for withdraw the SOL from compaign PDA. This function get 2 parameters 1: Withdraw struct and amount u64.
- donate(ctx: Context, amount: u64) -> ProgramResult Use for donate SOL to a compaign. This function get 2 parameters 1: Donate struct and amount u64.
- run this command in app folder
npm run
and open it on web browser - click on "Connect Wallet" button and connect the phantom wallet
- click on "Get All Compaign" Button that will show the all compaign and you can donate some fix SOL to any of that compaign through your wallet and if you create any compaign and you are the admin of that compaign then you can withdraw some fix SOL from your compaign
- click on "Create New Compaign" Button this will create new compaign against your wallet address and compaign name is hardcor