<>ts-stack
Get StartedArchitecturePackagesSpecsGuides
⌘K
Reference
Home
Get StartedOverviewInstallChoose your stackKey concepts
ArchitectureOverviewStack layersBEEF (BRC-62)BRC-100 Wallet InterfaceIdentity & AuthConformance pipeline
PackagesOverviewSDKWallet
@bsv/wallet-toolbox@bsv/btms@bsv/btms-permission-module@bsv/wallet-relay@bsv/wallet-toolbox-examples
NetworkOverlaysMessagingMiddlewareHelpers
InfrastructureOverviewmessage-box-serveroverlay-serveruhrp-server-basicuhrp-server-cloud-bucketwabwallet-infrachaintracks-serverwebrtpay-relay
SpecsOverviewBRC-100 Wallet InterfaceOverlay HTTPMessage-box HTTPAuthsocket (WebSocket)BRC-31 Auth HandshakeBRC-29 Peer PaymentBRC-121 / HTTP 402ARC BroadcastMerkle ServiceStorage AdapterGASP SyncUHRPAir-Gap Optical (BRC-141)
ConformanceOverviewVector catalogTS runnerContributing vectors
GuidesOverviewIdentity, DIDs and credentialsIdentity migrationBuild a wallet-aware appRun an overlay nodePeer-to-peer messagingHTTP 402 payments
ReferenceOverviewBRC indexRepository health
AboutVersioningContributingDoc agentDocumentation sources
npm@bsv/color-permission-modulev0.2.2experimentalAPI reference (TypeDoc) ↗
Loading…
Edit this page on GitHub
© 2026 BSV Blockchain. ts-stack is open-source.
GitHubContributingVersioning

@bsv/color-permission-module

@bsv/color-permission-module is the reference BRC-207 color wallet module for BRC-162 fungible tokens. A WalletPermissionsManager routes every p color protocol, basket and action label to it.

Install

bash
npm install @bsv/color-permission-module @bsv/wallet-toolbox-client @bsv/sdk

Setup

ts
import { createColorModule } from '@bsv/color-permission-module'
import { WalletPermissionsManager } from '@bsv/wallet-toolbox-client'

const color = createColorModule({
  wallet: setup.wallet,
  provider: colorOverlayProvider,
  requestTokenAccess: async (originator, message) =>
    await showTokenPrompt(originator, JSON.parse(message))
})

const wallet = new WalletPermissionsManager(setup.wallet, adminOriginator, {
  permissionModules: { color }
})

wallet is the underlying wallet the permissions manager wraps. provider answers the BRC-207 color-spendability and color-admission queries and submits transactions to tm_color_<assetId>; the host decides which overlays it trusts. requestTokenAccess shows the user each token send, signature request and read (color_access names the basket, asset and role or the p color labels read, and the caller's seekPermission), and returns true to approve.

Application calls

OperationCall
Send tokenscreateAction with the BRC-162 recipient output, p color plan labels from ColorPlan.toLabels and options.randomizeOutputs: false (every plan requires it)
Deploy, mint, burn, authorityThe same call with the plan declaring the BRC-207 operations the transaction performs
Hand off under BRC-177The same call with a p nosend expiry label and noSend (the only noSend token action without a plain-noSend profile)
Receive tokensinternalizeAction with basket insertion into p color <assetTag> and the BRC-207 receipt instructions
Sign an app-built transactioncreateSignature with a p color protocol ID and a BRC-207 signature envelope
Discover holdingslistOutputs on p color assets
BalancelistOutputs on p color balance <assetTag>; totalOutputs is a number, exact to 2^53

Required profiles

Hosts that support assets with BRC-207 required processing profiles pass profiles (handlers keyed by profile id) and a durable store (ColorModuleStore) to createColorModule. The registry fails closed: every profile an asset requires must be registered, and handlers only restrict. A handler's admitReceipt decides each receipt of its asset as settled or pending; pending receipts and the change of a plain-noSend hand-over are tagged color_offline until the host calls the in-process markSettled(txid) after submitting them. The pending balance, p color balance <assetTag> with tags: ['color_offline'], is a number like every balance, and pending outputs stay in p color assets with their color_state_* tag. Receipts carry BRC-207 custody instructions only; the module transports and validates no token history. Errors carry a [ClassName] message prefix; a declined request throws ColorConsentDeclinedError. Without profiles the module behaves as 0.1.1, apart from seekPermission on every consent message and ColorConsentDeclinedError on a decline. See the package README for each handler hook.

Limits

This version reads BRC-161 JSON transfer, mint and deploy+mint outputs as value and auth and deploy+auth as authority, as inputs and as outputs to other parties, but never holds or creates them, rejects the BRC-161 burn operation, satoshi change positions (wallet-toolbox does not position satoshi change) and assets whose required processing profiles no registered handler supports, does not validate BRC-176 lineage (proof transport is not part of BRC-207), and does not yet record exposure for signatures released through createSignature. With required profiles it also refuses createSignature for assets whose profiles define sendPolicy, submissionData or checkPlanData, any receipt profileData, and a plain-noSend hand-over signed with options.noSend: false or a sendWith batch. BRC-207's non-final transaction rules are not implemented; such transactions follow the wallet's existing behavior. A send is approved in signAction, against the funded transaction; a createSignature request is approved against the whole app-built transaction, after every token input is found admitted and unspent. A receipt relies on its overlay's admission of the received output for the transaction's token amounts; the module does not re-evaluate them. Reads (p color assets and balances) report wallet state alone and never query the overlay; spendability is checked only when spending. p color assets and the check of an app's explicit token inputs read every held token output in one listing; wallet-toolbox refuses that listing above 10,000 outputs.

Derivative modules subclass ColorPermissionModule, whose members are protected, and use its exported evaluation helpers (transactionTokens, requiredOperations, actionConsent, the token readers).