Fund a book
For the owner: open a book, put money in, and take it out.
In the app
- Connect your wallet and open the Book page.
- A new wallet sees Open your book. Press it and sign.
- Press Deposit, enter an amount and sign.
- The balance goes up and the Ledger shows a Deposit entry.
The app has no Withdraw button yet. Withdrawing is a program call.
With the program
await program.methods
.openBook()
.accounts({ owner: owner.publicKey, mint, tokenProgram: TOKEN_PROGRAM_ID })
.rpc();
await program.methods
.deposit(new BN(500_000_000)) // 500 c$
.accounts({ owner: owner.publicKey, book, mint, vault, ownerToken, tokenProgram: TOKEN_PROGRAM_ID })
.rpc();withdraw takes the same accounts as deposit and moves tokens from the vault back to ownerToken. It refuses with InsufficientBalance if the vault holds less than the amount.
A book is tied to the mint it was opened with. One owner key has one book.
NextIssue a wallet and set its limits