# Snippets

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](https://bitbadges.io/developer). See [BitBadges API](https://docs.bitbadges.io/api).

| Page | Use it for |
| --- | --- |
| [Address Conversions](https://docs.bitbadges.io/sdk/snippets/address-conversions) | `0x` and `bb1` conversion, address validation |
| [Uint Ranges](https://docs.bitbadges.io/sdk/snippets/uint-ranges) | `UintRange` and `UintRangeArray`: merge, search, invert, remove, overlaps |
| [Balances](https://docs.bitbadges.io/sdk/snippets/balances) | `BalanceArray`: add, subtract, look up by token ID and time |
| [Balance Lookups](https://docs.bitbadges.io/sdk/snippets/balance-lookups) | Fetch a balance from the API, the chain, or the CLI; full array vs single amount |
| [Transfers](https://docs.bitbadges.io/sdk/snippets/transfers) | `TransferWithIncrements` for batch and sequential distribution |
| [Address Lists](https://docs.bitbadges.io/sdk/snippets/address-lists) | `AddressList`: membership checks, inversion, reserved lists |
| [Token Metadata](https://docs.bitbadges.io/sdk/snippets/token-metadata) | `TokenMetadataDetails`: update, remove, and read metadata per token ID |
| [Approvals](https://docs.bitbadges.io/sdk/snippets/approvals) | Find unhandled (disapproved) approval combinations, append default user approvals |
| [Interpret a Collection](https://docs.bitbadges.io/sdk/snippets/interpret-collection) | `interpretCollection`: a plain-language report of an on-chain collection |
| [Interpret a Transaction](https://docs.bitbadges.io/sdk/snippets/interpret-transaction) | `interpretTransaction`: a plain-language report of an unsigned `MsgUniversalUpdateCollection` |
| [Simulation Balance Diffs](https://docs.bitbadges.io/sdk/snippets/simulation-balance-diffs) | `simulateAndReview`, `parseSimulationEvents`, `calculateNetChanges` |

Concepts behind these helpers live in the [Token standard](https://docs.bitbadges.io/token-standard/concepts). The generated API is at the [SDK reference](https://docs.bitbadges.io/sdk/reference).
