Skip to content
LogoLogo

Account.fromMultisig

Instantiates an Account for a native multisig. Omit address or set it to infer to derive the canonical CREATE2 account address. After the config changes, use the stable address and pass the current config fields.

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({
  address: 'infer',
  owners: [owner_1, owner_2],
  threshold: 2,
})
 
console.log('Address:', account.address)

Account.fromMultisig normalizes the config with MultisigConfig.from, including canonical owner ordering. The initial config always uses version 0.

Current Config

After a config update, reconstruct the account from its stable address and current config. The address does not change when the config changes.

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

Tempo stores the config commitment, not the config fields. Retain each current config or recover it from the account's MultisigConfigUpdated events.

Address Only

Use an address-only account when only the stable account identity is needed.

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

An address-only account contains no config or local owner keys. A coordinated client can load the current config from its store. Otherwise, provide the config through { address, ...config } before sending.

External Owners

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

import { Account } from 'viem/tempo'
 
const account = Account.fromMultisig({
  address: 'infer',
  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({
  address: 'infer',
  owners: [
    { owner, weight: 2 },
    { owner: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8', weight: 1 },
  ],
  threshold: 2,
})

Return Type

type ReturnType = MultisigAccount
 
type MultisigAccount = LocalAccount<'multisig'> & {
  /** Normalized config, 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: Account.fromMultisig.Parameters

An initial config, a stable address with its current config, or an address without a retained config.

value.address

  • Type: 'infer' | Address | undefined

Omit this field or set it to infer to derive an account from a version-zero config. For a current config, pass the account's stable address. Pass an Address as value when no config is needed.

value.owners

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

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

value.salt

  • Type: Hex
  • Default: 0x0000000000000000000000000000000000000000000000000000000000000000

The 32-byte config salt. This field is optional for an initial config and required for a current config.

value.threshold

  • Type: number
  • Default: 1

The total owner weight required to authorize an operation. This field is optional for an initial config and required for a current config.

value.version

  • Type: bigint | number

The nonzero current config version. For an initial config, omit this field or pass 0 when spreading a normalized MultisigConfig.Config value.