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 a new review for a collection or address.
POST /api/v0/reviews/add
await BitBadgesApi.addReview(collectionId, payload);
const res = await BitBadgesApi.addReview(collectionId, payload);
console.log(res);
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.
POST /api/v0/auth/status
await BitBadgesApi.checkIfSignedIn(payload);
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.
POST /api/v0/claims/complete/:claimId/:cosmosAddress
await BitBadgesApi.completeClaim(claimId, address, { ...body });
const res = await BitBadgesApi.completeClaim(claimId, address, { ...body });
console.log(res);
Creates address lists stored by BitBadges centralized servers.
POST /api/v0/addressLists
await BitBadgesApi.updateAddressLists(payload);
Must be created off-chain. For on-chain, they must be created through MsgCreateAddressMappings. Creator can update their created lists with no restrictions. Else, requires an edit key.
Creates an off-chain attestation signature (typically a credential).
POST /api/v0/attestation
await BitBadgesApi.createAttestation(payload);
Creates an off-chain attestation proof (typically a credential).
POST /api/v0/attestationProof
await BitBadgesApi.createAttestationProof(payload);
Creates a claim.
POST /api/v0/claims
await BitBadgesApi.createClaim(payload);
Creates a SIWBB request.
Optional
payload: CreateSIWBBRequestPayloadPOST /api/v0/siwbbRequest
await BitBadgesApi.createSIWBBRequest(payload);
Deletes address lists. Must be created off-chain.
DELETE /api/v0/addressLists
await BitBadgesApi.deleteAddressLists(payload);
Deletes an off-chain attestation signature (typically a credential).
DELETE /api/v0/attestation
await BitBadgesApi.deleteAttestation(payload);
Deletes an off-chain attestation proof (typically a credential).
DELETE /api/v0/attestationProof
await BitBadgesApi.deleteAttestationProof(payload);
Deletes a claim.
DELETE /api/v0/claims
await BitBadgesApi.deleteClaim(payload);
Deletes a review.
Optional
payload: DeleteReviewPayloadDELETE /api/v0/deleteReview/:reviewId
await BitBadgesApi.deleteReview(reviewId, payload);
const res = await BitBadgesApi.deleteReview(reviewId);
console.log(res);
Deletes a SIWBB request.
Optional
payload: DeleteSIWBBRequestPayloadDELETE /api/v0/siwbbRequest
await BitBadgesApi.deleteSIWBBRequest(payload);
Gets and verifies a SIWBB request.
Optional
payload: ExchangeSIWBBAuthorizationCodePayloadPOST /api/v0/siwbbRequest
await BitBadgesApi.exchangeSIWBBAuthorizationCode(payload);
Filters badges in a collection based on multiple filter values.
POST /api/v0/collection/:collectionId/filter
await BitBadgesApi.filterBadgesInCollection(payload);
Gets the filter suggestions based on attributes in a collection.
Optional
payload: FilterSuggestionsPayloadPOST /api/v0/collection/:collectionId/filterSuggestions
await BitBadgesApi.filterSuggestions(payload);
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 address lists. Can be on-chain or off-chain.
POST /api/v0/addressLists
await BitBadgesApi.getAddressLists(payload);
Note for reserved lists, you can use getReservedAddressList from the SDK.
Get an off-chain attestation signature (typically a credential).
POST /api/v0/attestation
await BitBadgesApi.getAttestation(payload);
Get an off-chain attestation proof (typically a credential).
POST /api/v0/attestationProof
await BitBadgesApi.getAttestationProof(payload);
Gets the activity for a specific badge in a collection
POST /api/v0/collection/:collectionId/:badgeId/activity
await BitBadgesApi.getBadgeActivity(collectionId, badgeId, payload);
const res = await BitBadgesApi.getBadgeActivity(collectionId, badgeId, { bookmark: 'prev' });
console.log(res);
Gets the balance of a specific badge for a specific address
Optional
payload: GetBadgeBalanceByAddressPayloadPOST /api/v0/collection/:collectionId/balance/:cosmosAddress
await BitBadgesApi.getBadgeBalanceByAddress(collectionId, cosmosAddress);
const res = await BitBadgesApi.getBadgeBalanceByAddress(collectionId, cosmosAddress);
console.log(res);
Gets details for a browse / explore page.
Optional
payload: GetBrowseCollectionsPayloadPOST /api/v0/browse
await BitBadgesApi.getBrowseCollections(payload);
Gets claim alerts for a collection.
POST /api/v0/claimAlerts
await BitBadgesApi.getClaimAlerts(payload);
Gets the status of a claim attempt.
POST /api/v0/claims/status/:claimId
await BitBadgesApi.getClaimAttemptStatus(claimAttemptId);
const res = await BitBadgesApi.getClaimAttemptStatus(claimAttemptId);
console.log(res);
Gets the claim by ID.
POST /api/v0/claims
await BitBadgesApi.getClaims(payload);
const res = await BitBadgesApi.getClaims(payload);
console.log(res);
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 map values
POST /api/v0/mapValues
await BitBadgesApi.getMapValues(payload);
Get maps by ID
POST /api/v0/maps
await BitBadgesApi.getMaps(payload);
Gets the owners for a specific badge in a collection
POST /api/v0/collection/:collectionId/:badgeId/owners
await BitBadgesApi.getOwnersForBadge(collectionId, badgeId, payload);
const res = await BitBadgesApi.getOwnersForBadge(collectionId, badgeId, { bookmark: 'prev' });
console.log(res);
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.
POST /api/v0/collection/:collectionId/refreshStatus
await BitBadgesApi.getRefreshStatus(payload);
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/:cosmosAddress
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.
POST /api/v0/developerApp/siwbbRequests
await BitBadgesApi.getSIWBBRequestsForDeveloperApp(payload);
Search collections, badges, accounts, address lists based on a search value.
Optional
payload: GetSearchPayloadPOST /api/v0/search/:searchValue
await BitBadgesApi.getSearchResults(searchValue);
const res = await BitBadgesApi.getSearchResults('vitalik.eth', { noAddressLists: true, noCollections: true, noBadges: true });
console.log(res);
Gets the current status details about the blockchain / indexer (gas, block height, etc).
POST /api/v0/status
await BitBadgesApi.getStatus();
const res = await BitBadgesApi.getStatus();
console.log(res);
Triggers 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: RefreshMetadataPayloadPOST /api/v0/collection/:collectionId/refresh
await BitBadgesApi.refreshMetadata(collectionId, payload);
const res = await BitBadgesApi.refreshMetadata(collectionId);
console.log(res);
Revokes an access token for a user.
POST /api/v0/siwbb/token/revoke
await BitBadgesApi.oauthRevoke(payload);
Rotates a SIWBB request.
POST /api/v0/siwbbRequest/rotate
await BitBadgesApi.rotateSIWBBRequest(payload);
Sends claim alert notifications out.
POST /api/v0/claimAlerts/send
await BitBadgesApi.sendClaimAlert(payload);
Simulates a claim attempt. A success response means the claim is valid and can be completed.
POST /api/v0/claims/simulate/:claimId/:cosmosAddress
await BitBadgesApi.simulateClaim(claimId, address, { ...body });
const res = await BitBadgesApi.simulateClaim(claimId, address, { ...body });
console.log(res);
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.
POST /api/v0/user/updateAccount
await BitBadgesApi.updateAccountInfo(payload);
const res = await BitBadgesApi.updateAccountInfo(payload);
console.log(res);
Updates address lists stored by BitBadges centralized servers.
PUT /api/v0/addressLists
await BitBadgesApi.updateAddressLists(payload);
Must be created off-chain. For on-chain, they must be created through MsgCreateAddressMappings. Creator can update their created lists with no restrictions. Else, requires an edit key.
Update a attestation.
PUT /api/v0/attestation
await BitBadgesApi.updateUserAttestations(payload);
Update an claim.
PUT /api/v0/claims
await BitBadgesApi.updateClaim(payload);
Update Helper Functions for Pagination and Dynamic Fetches
A generic route for verifying asset ownership requirements. Asset requirements support AND / OR / NOT logic.
POST /api/v0/verifyOwnershipRequirements
await BitBadgesApi.verifyOwnershipRequirements(payload);
A generic route for verifying SIWBB requests. Used as a helper if implementing on your own.
POST /api/v0/siwbbRequest/verify
await BitBadgesApi.verifySIWBBRequest(payload);
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