Understanding wallet structure
In Blnk, wallets are represented as balances. Each balance tracks:- Balance: Current available funds
- Credit balance: Total incoming funds
- Debit balance: Total outgoing funds
- Inflight balance: Funds held in pending transactions
Creating a wallet
Create a balance to represent a user’s wallet:Making a deposit
Deposit funds from an external source into a user’s wallet:Record deposit transaction
The
@world indicator represents an external source. Blnk automatically creates this special balance if it doesn’t exist.Processing a withdrawal
Withdraw funds from a user’s wallet to an external account:Transferring between wallets
Transfer funds between two user wallets:Checking balance
Retrieve the current balance of a wallet:Using balance indicators
Balance indicators provide a convenient way to reference balances without knowing their IDs:- Look for a balance with indicator
@[email protected]and currencyUSD - Create it if it doesn’t exist
- Use it in the transaction
Best practices
Use unique references
Always use unique transaction references to prevent duplicate transactions.
Include metadata
Store additional context in
meta_data for audit trails and reconciliation.Precision matters
Always set precision to 100 for standard currencies to handle cents accurately.
Check balances
Verify sufficient funds before processing withdrawals or transfers.
Common patterns
Multi-currency wallets
Create separate balances for each currency:Fee handling
Use distributions to split transactions and collect fees:Next steps
Inflight Transactions
Learn how to hold funds for pending operations
Balance Monitoring
Set up alerts for balance changes