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.
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-appcd ./solana-appnpm imkdir -p ./keyscd ./keyssolana-keygen grind --starts-with Pro:1solana-keygen grind --starts-with Log:1solana-keygen grind --starts-with Dev:1for file in *.json; do cp "$file" "${file%.json}-keypair.json"; donecd ..- Manually change the path to the provider.wallet to point to ./keys/Dev...json AND run
solana config set --keypair DevYourAddressHereto specify initial payer and upgrade authority of the new program. anchor build --arch sbfmv 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 generatenpx prisma migrate devsolana-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.tsnpx tsx ./app/call.tsnpx prisma studio- Each time you call the program use Prisma Studio to observe a new transaction signature and blocktime in the db.