Skip to content
LogoLogo

Account.fromMultisig

Instantiates an Account for a native multisig. Pass an initial config to derive and bootstrap an account, or pass the address of an initialized account to reconstruct it.

Owners can be local accounts, addresses, or weighted owner entries. Direct owners have a weight of 1, and threshold defaults to 1.

Local owner accounts are retained so the returned account can aggregate their approvals when you call signTransaction. Address-only owners support distributed signing, where each owner signs the same prepared request and the sender supplies the resulting signatures.

Usage

import { Account } from 'viem/tempo'
 
const owner_1 = Account.fromSecp256k1(
  '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
)
const owner_2 = Account.fromSecp256k1(
  '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'
)
 
const account = Account.fromMultisig({
  owners: [owner_1, owner_2],
  threshold: 2,
})
 
console.log('Address:', account.address)

Account.fromMultisig normalizes the config with MultisigConfig.from, including canonical owner ordering. You can also pass a pre-built MultisigConfig.Config.

Initialized Account

After bootstrap, reconstruct the account from its stable address. Request preparation reads the current owners, threshold, and version from the multisig precompile.

import { Account } from 'viem/tempo'
 
const account = Account.fromMultisig(
  '0x0000000000000000000000000000000000000001'
)

The address form cannot bootstrap an uninitialized account or aggregate local owner signatures. Collect approvals independently and pass them to the prepared request's signatures field.

External Owners

Pass addresses when owner approvals are collected outside the current process.

import { Account } from 'viem/tempo'
 
const account = Account.fromMultisig({
  owners: [
    '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
    '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
  ],
  threshold: 2,
})

Weighted Owners

Pass { owner, weight } entries to give owners different approval weights.

import { Account } from 'viem/tempo'
 
const owner = Account.fromSecp256k1(
  '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
)
 
const account = Account.fromMultisig({
  owners: [
    { owner, weight: 2 },
    { owner: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8', weight: 1 },
  ],
  threshold: 2,
})

Return Type

type ReturnType = MultisigAccount
 
type MultisigAccount = LocalAccount<'multisig'> & {
  /** Normalized initial configuration, when supplied. */
  config: MultisigConfig.Config | undefined
  /** @internal Local owner accounts retained for signing. */
  owners: readonly LocalAccount[]
}

The account's signTransaction method combines retained local owner approvals with any approvals provided through the request's signatures. sign, signMessage, and signTypedData are not supported.

Parameters

value

  • Type: Address | Account.fromMultisig.Config

An initialized multisig address or the initial config used to derive and bootstrap an account.

value.owners

  • Type: readonly (Address | LocalAccount | { owner: Address | LocalAccount; weight: number })[]

The initial owners. Passing a local account makes that account available for local aggregation. Passing an address keeps that owner's approval external.

value.threshold (optional)

  • Type: number
  • Default: 1

The total owner weight required to authorize a transaction.

value.salt (optional)

  • Type: Hex
  • Default: 0x0000000000000000000000000000000000000000000000000000000000000000

A 32-byte salt used to derive a distinct address for the same owner set and threshold.