This is a starter app to demonstrate how to integrate jupiter lock within a react app (the steps will be identical for integrating with any js frontend web app)
TLDR:
- generate the jup-lock idl
- use codama to generate js client code to interact with the jup-lock program from the idl
- copy
createLock.ts
andqueryLocks.ts
files from this repo to your app
- web3js v2
- @solana-program/token
- @solana-program/system (create lock)
- @solana/webcrypto-ed25519-polyfill (create lock)
- git clone https://github.com/jup-ag/jup-lock
- install solana, anchor cli via this guide: https://solana.com/docs/intro/installation
- run
anchor build
- copy the file
./target/idl/locker.json
to your web app
- copy this folder into your project: https://github.com/jup-ag/jup-lock-starter/tree/cc8828106afa04b6ae907b344b444e3cf46981a2/idl
- replace the
idl.json
with./target/idl/locker.json
u generated previously and rename itidl.json
- run the
generate-ts.ts
file - u should see a
src/lib
folder get generated with all the ts client code required for interacting with the lock program
- create lock:
jup-lock-starter/src/lock/createLock.ts
Line 85 in cc88281
- query lock by user:
jup-lock-starter/src/lock/queryLock.ts
Line 30 in cc88281
To run this application:
bun install
bun start
To build this application for production:
bun run build