getModules

Lists module deploys indexed by the connected Bitcoin Computer Node.

Type

type ModuleRecord = {
  mod: string
  ept: string
  storageType: 'multisig' | 'taproot'
  blockHash?: string | null
  blockHeight?: number | null
  timestamp?: string | number
}

type ModuleQuery = {
  verbosity?: number
  limit?: number
  offset?: number
  order?: 'ASC' | 'DESC'
  storageType?: 'multisig' | 'taproot'
  isConfirmed?: boolean
}

async getModules(q?: ModuleQuery & { verbosity?: 0 }): Promise<string[]>
async getModules(q: ModuleQuery & { verbosity: 1 }): Promise<ModuleRecord[]>
async getModules(q?: ModuleQuery): Promise<string[] | ModuleRecord[]>

Parameters

query (optional)

Key Description
verbosity 0 (default): module specifier strings. 1: full ModuleRecord rows including source (ept)
limit Maximum number of results
offset Number of results to skip
order Sort by node insert timestamp: ASC or DESC (default DESC)
storageType Filter by on-chain encoding: multisig or taproot
isConfirmed true: only confirmed modules; false: mempool only

Return Value

  • verbosity 0string[] of module specifiers (<txId>:0)
  • verbosity 1ModuleRecord[] with source text and confirmation fields

Description

Calls the node’s GET /modules endpoint. The node indexes module deploys (multisig cleartext { ept } or taproot BC witness) into its Module table when they appear in the mempool or a block.

This method does not evaluate modules. Use load to import exports in a SES compartment. Use getModule for a single known specifier.

After deploy, allow a short delay (or poll) until the indexer has the row. Confirmation fields are set when the deploy is in a block; they are cleared on reorg.

Example

const mod = await computer.deploy(`export const x = 1`)

// Specifiers only
const mods = await computer.getModules({ limit: 50 })
expect(mods.includes(mod)).to.equal(true)

// Full rows, filter by storage type
const rows = await computer.getModules({
  verbosity: 1,
  storageType: 'taproot',
  isConfirmed: true,
  limit: 20,
})
for (const row of rows) {
  console.log(row.mod, row.ept.slice(0, 40))
}

See also