Skip to content
SolRengine
Case study

PiggyBank — time-locked SOL savings on-chain

Lock SOL until a future date with a custom Anchor program, driven entirely from Rails — IDL parsing, Borsh encoding, and on-chain account queries with SolRengine.

auth rpc programs realtime devnet
Live demo View source
piggybank.solrengine.org
PiggyBank — time-locked SOL savings on-chain screenshot

PiggyBank lets you lock SOL on-chain until a time of your choosing, then unlock it once the timer expires. It’s small on purpose — the point is to show how a Rails app talks to a custom Anchor program: parsing its IDL, Borsh-encoding instructions, and reading the resulting accounts back off the chain.

If Mercado shows payments and WalletTrain shows breadth, PiggyBank shows the solrengine-programs gem doing the unglamorous-but-essential work of speaking a program’s binary language from Ruby.

What it does

The program

PiggyBank drives the Cyfrin PiggyBank Anchor program on devnet:

How a lock happens

The split of responsibility is the interesting part — the server encodes, the client signs:

1. Client generates a fresh keypair for the lock account
2. Server Borsh-encodes the instruction data (amount + expiration) from the IDL
3. Wallet signs and sends the transaction (client-side)
4. Lock accounts are queried straight from the chain and rendered as a list
5. Once a lock's expiration passes, the unlock instruction becomes available

The Rails database stores almost nothing about the locks themselves — they live on Solana, and solrengine-programs decodes their raw account bytes back into Ruby objects (PiggyBank::Lock) for display, with a live countdown ticking down to each expiration.

The SolRengine gems behind it

Try it

← All showcases Build your own →