Skip to content

Build and query AddressList objects in the bitbadges SDK, membership checks, inversion, removal, and the reserved Mint and All lists.

AddressList is a whitelist or blacklist of addresses with an ID. It is the base type behind every fromList, toList, and initiatedByList in approvals, and BitBadgesAddressList from the API extends it.

Example

ts
import { AddressList } from 'bitbadges';

const BOB = 'bb1py4mfpg6uf59qkyzg0nmau322c5873eeysp5ue';

const list = new AddressList({
  listId: 'demo-allowlist',
  addresses: [BOB],
  whitelist: true,
  uri: '',
  customData: '',
  createdBy: 'bb1p0rrel3365scadq5k9pv0x0zp9j22js6dnw70d'
});

list.checkAddress(BOB); // true

const inverted = list.toInverted(); // whitelist: false, same addresses
inverted.checkAddress(BOB); // false

list.remove(BOB); // in place
list.isEmpty(); // true

const mintList = AddressList.Reserved('Mint'); // only the Mint address
const all = AddressList.AllAddresses(); // every address
const allButBob = AddressList.Reserved(`!${BOB}`);

Behavior

CallReturnsNotes
checkAddress(address)booleanMembership after applying whitelist
invert() / toInverted()this / newFlips whitelist
remove(addresses) / toRemoved(addresses)this / newAccepts one address or another list
union(other) / toUnion(other)this / newMerges membership
getOverlaps(other) / getOverlapDetails(other)list / [inThisOnly, both, inOtherOnly]Set algebra
isEmpty()booleanNo address passes checkAddress
AddressList.Reserved(id)listParses a reserved ID: Mint, All, AllWithMint, None, AllWithout<addr:addr>, one address, addr:addr joined addresses, and a ! prefix to invert. Throws on an unknown ID
AddressList.AllAddresses()listSame as Reserved('All')

Lists created on chain with MsgCreateAddressLists are immutable. Reserved IDs never need to be created.

Edit this page on GitHub