Skip to content

bespy/solana-app

Repository files navigation

Solana App

My Solana App is bootstrapped with anchor-cli and includes a Solana Program written in Rust and a NodeJS Backend Service. The Solana Program is a Smart Contract that is deployable to local network (localnet) and writes transactions to the Blockchain when it is invoked. The backend service includes an on-chain event listener that utilises a Websocket connection and a transaction parser that utilises a Http connection to the local RPC. I am using Solana Kite for convenience methods.

Getting Started

Running this project assumes you are familiar with Rust, TypeScript, npm, npx, tsx, Cargo and Anchor and have followed the Solana Quickstart Guide to set up you local machine.

  • git clone https://github.com/bespy/solana-app
  • cd ./solana-app
  • npm i
  • mkdir -p ./keys
  • cd ./keys
  • solana-keygen grind --starts-with Pro:1
  • solana-keygen grind --starts-with Log:1
  • solana-keygen grind --starts-with Dev:1
  • for file in *.json; do cp "$file" "${file%.json}-keypair.json"; done
  • cd ..
  • Manually change the path to the provider.wallet to point to ./keys/Dev...json AND run solana config set --keypair DevYourAddressHere to specify initial payer and upgrade authority of the new program.
  • anchor build --arch sbf
  • mv keys/*-keygen.json target/deploy/
  • manually change the filename of target/deploy/ProYourAddressHere-keypair.json file to event_listener-keypair.json
  • manually change the ProYourAddressHere address in the file Anchor.toml to your "Pro..." address...
  • manually change the declare_id!('Pro...') in the file ./programs/event_logger/src/lib.rs to your ProYourAddressHere address
  • npx prisma generate
  • npx prisma migrate dev
  • solana-test-validator --reset --limit-ledger-size 100000
  • Open a second terminal for the next series of commands...
  • solana airdrop 1 DevYourAddressHere -ul (optional as you will already have 5 SOL)
  • anchor deploy
  • The program should deploy with the ProYourAddressHere that you specified in the Anchor.toml, and
  • npx tsx ./app/listen.ts
  • npx tsx ./app/call.ts
  • npx prisma studio
  • Each time you call the program use Prisma Studio to observe a new transaction signature and blocktime in the db.

About

Solana Smart Contract Logging Program & Event Listener

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published