Adds approval details to off-chain storage.
POST /api/v0/addApprovalDetailsToOffChainStorage
await BitBadgesApi.addApprovalDetailsToOffChainStorage(payload);
const res = await BitBadgesApi.addApprovalDetailsToOffChainStorage(payload);
console.log(res);
Adds a balance map to off-chain storage. Mode can either be 'ipfs" for storing on IPFS or 'centralized' for storing on DigitalOcean.
POST /api/v0/addBalancesToOffChainStorage
await BitBadgesApi.addBalancesToOffChainStorage(payload);
const res = await BitBadgesApi.addBalancesToOffChainStorage(payload);
console.log(res);
Adds metadata to IPFS.
Broadcasts a transaction to the blockchain.
POST /api/v0/broadcast
await BitBadgesApi.broadcastTx(payload);
Also, consider checking out Broadcast UI, so you can simply copy and paste your transaction to a UI. All signing, API communication, etc is outsourced to the UI.
Checks if the user is signed in.
For password based approvals, we hand out codes behind the scenes whenever a user requests a password. This is to prevent replay attacks on the blockchain. This API call will return a valid code if a valid password is provided.
Each address is limited to one code per password. If the password is provided again, they will receive the same code.
Creates address lists stored by BitBadges centralized servers.
Creates an off-chain attestation signature (typically a credential).
Creates an off-chain attestation proof (typically a credential).
Creates a claim.
Creates an developer app.
Creates an internal action.
Creates a payment intent for the user to pay.
Creates a plugin.
Creates a SIWBB request.
Optional
payload: CreateSIWBBRequestPayloadDeletes address lists. Must be created off-chain.
Deletes an off-chain attestation signature (typically a credential).
Deletes an off-chain attestation proof (typically a credential).
Deletes a claim.
Deletes an developer app.
Deletes an internal action.
Deletes a plugin.
Deletes a SIWBB request.
Optional
payload: DeleteSIWBBRequestPayloadGets and verifies a SIWBB request.
Optional
payload: ExchangeSIWBBAuthorizationCodePayloadFetches arbitrary metadata directly from IPFS. This is useful for fetching metadata that is not stored on-chain.
Filters badges in a collection based on multiple filter values.
Gets the filter suggestions based on attributes in a collection.
Optional
payload: FilterSuggestionsPayloadGenerates an Apple wallet pass for a code.
Returns application/vnd.apple.pkpass content type.
POST /api/v0/siwbbRequest/appleWalletPass
await BitBadgesApi.generateAppleWalletPass(payload);
const res = await BitBadgesApi.generateAppleWalletPass(payload);
console.log(res);
const pass = Buffer.from(res.data);
const blob = new Blob([pass], { type: 'application/vnd.apple.pkpass' });
const url = window.URL.createObjectURL(blob);
if (url) {
const link = document.createElement('a');
link.href = url;
link.download = 'bitbadges.pkpass';
link.click()
}
Generates an Google wallet pass for a code. Returns a saveUrl to be opened.
Gets accounts and accompying details.
POST /api/v0/users
await BitBadgesApi.getAccounts(payload);
const res = await BitBadgesApi.getAccounts([{ address, fetchSequence: true, fetchBalance: true }]);
console.log(res);
This function is used to fetch accounts and their details. It is your responsibility to join the data together (paginations, etc). Use getAccountsAndUpdate for a more convenient way to handle paginations and appending metadata.
Gets all active authorizations for a user.
Gets address lists. Can be on-chain or off-chain.
Get an off-chain attestation signature (typically a credential).
Get an off-chain attestation proof (typically a credential).
Gets the activity for a specific badge in a collection
Gets the balance of a specific badge for a specific address
Optional
payload: GetBadgeBalanceByAddressPayloadGets details for a browse / explore page.
Optional
payload: GetBrowseCollectionsPayloadGets claim alerts for a collection.
Gets the status of a claim attempt.
Gets the claim by ID.
This function retrieves badge collections and accompanying details. Consider using the getCollectionsAndUpdate
function instead for native support in handling paginations, appending metadata, and more.
POST /api/v0/collections
const res = await BitBadgesApi.getCollections([{ collectionId, metadataToFetch: { badgeIds: [{ start: 1n, end: 10n }] } }]);
const collection = res.collections[0];
Get all developer apps for a user.
Get the gated content for a claim.
Gets internal actions.
Get map values
Get maps by ID
Gets the owners for a specific badge in a collection
Get all developer apps for a user.
Gets the refresh status for a collection. Used to track if any errors occur during a refresh, or if it is in the queue or not.
For on-chain claims where codes are "reserved" for a specific address, this function will return all codes reserved.
POST /api/v0/claims/reserved/:claimId/:address
await BitBadgesApi.getReservedClaimCodes(claimId, address, { ...body });
const res = await BitBadgesApi.getReservedClaimCodes(claimId, address, { ...body });
console.log(res);
Gets the SIWBB requests for a specific developer app.
Search collections, badges, accounts, address lists based on a search value.
Optional
payload: GetSearchPayloadGets the sign in challenge to be signed for authentication. The returned is the message to be signed by the user.
Gets the current status details about the blockchain / indexer (gas, block height, etc).
Gets the tokens from the faucet. This will only work on betanet.
Optional
payload: GetTokensFromFaucetPayloadTriggers a metadata refresh for a specific collection. BitBadges API uses a refresh queue system for fetching anything off-chain. This will refetch any details for the collection (such as metadata, balances, approval details, etc). Note it will reject if recently refreshed. Uses a cooldown of 5 minutes.
Optional
payload: RefreshMetadataPayloadRevokes an access token for a user.
Rotates a SIWBB request.
Sends claim alert notifications out.
Signs the user out.
Optional
payload: SignOutPayloadSimulates a claim attempt. A success response means the claim is valid and can be completed.
Simulates a transaction on the blockchain.
POST /api/v0/simulate
await BitBadgesApi.simulateTx(payload);
This means that it will return the gas used and any errors that occur on a dry run. Should be used before broadcasting a transaction. Does not require signatures.
Updates the profile / account information for a user. We will only update the provided fields.
Updates address lists stored by BitBadges centralized servers.
Update a attestation.
Update an claim.
Update an developer app.
Updates an internal action.
Updates a plugin.
Update Helper Functions for Pagination and Dynamic Fetches
A generic route for verifying asset ownership requirements. Asset requirements support AND / OR / NOT logic.
A generic route for verifying SIWBB requests. Used as a helper if implementing on your own.
Verifies the user signed challenge and grants them a valid session if everything checks out.
This is the BitBadgesAPI class which provides all typed API calls to the BitBadges API. See official documentation for more details and examples. Must pass in a valid API key.
convertFunction is used to convert any responses returned by the API to your desired NumberType.
By default, we use the official API URL (https://api.bitbadges.io). You can override this by passing in a custom apiUrl.
See
BitBadges API Documentation