Snippets
Verified TypeScript examples for the bitbadges SDK helpers, balances, uint ranges, transfers, address lists, metadata, approvals, and interpreters.
Working examples for the SDK helper classes and functions. Each snippet imports from bitbadges and uses the names exported by the current package.
Snippets that construct a BitBadgesAPI client read BITBADGES_API_KEY. Create a key at bitbadges.io/developer. See BitBadges API.
| Page | Use it for |
|---|---|
| Address Conversions | 0x and bb1 conversion, address validation |
| Uint Ranges | UintRange and UintRangeArray: merge, search, invert, remove, overlaps |
| Balances | BalanceArray: add, subtract, look up by token ID and time |
| Balance Lookups | Fetch a balance from the API, the chain, or the CLI; full array vs single amount |
| Transfers | TransferWithIncrements for batch and sequential distribution |
| Address Lists | AddressList: membership checks, inversion, reserved lists |
| Token Metadata | TokenMetadataDetails: update, remove, and read metadata per token ID |
| Approvals | Find unhandled (disapproved) approval combinations, append default user approvals |
| Interpret a Collection | interpretCollection: a plain-language report of an on-chain collection |
| Interpret a Transaction | interpretTransaction: a plain-language report of an unsigned MsgUniversalUpdateCollection |
| Simulation Balance Diffs | simulateAndReview, parseSimulationEvents, calculateNetChanges |
Concepts behind these helpers live in the Token standard. The generated API is at the SDK reference.