Minter Docsv3.3.0
Developers / Multisig (0x0C)
Developers

Multisig (0x0C)

Weighted multisig accounts in Minter v3.3.0: CreateMultisig (0x0C), EditMultisig (0x12), SignatureMulti (0x02) assembly, and an isolated Cooler policy signer.

CreateMultisig (0x0C) creates a protocol Mx... account configured with 1 to 32 unique participant addresses[], per-signer weights[] (each <= 1023), and a threshold (threshold <= sum(weights)). ExecutorV3 executes any of the 37 active transaction types from that address under signatureType = 0x02 once the weights of unique valid signers reach threshold.

Creation (0x0C), rotation (0x12) and SignatureMulti

OpcodeOperationFee (USDTE)Inner RLP data schemaProtocol constraints
0x0CCREATE_MULTISIG$0.10[threshold: u32, weights: u32[], addresses: bytes20[]]1..32 unique Mx... addresses; weight <= 1023; threshold <= sum(weights)
0x12EDIT_MULTISIG$0.10[threshold: u32, weights: u32[], addresses: bytes20[]]Sent from the multisig address itself (signatureType = 0x02)

The created multisig address is derived deterministically from the creator's address and creation transaction nonce: deriveMultisigAddress(creatorMx, nonce) (Keccak256(RLP([creator20B, nonce]))[12..32]).

Rules for assembling SignatureMulti (signatureType = 0x02):

  1. Set nonce to transaction_count + 1n of the multisig account itself (a newly created multisig starts at transaction_count = 0, so its first outgoing transaction uses nonce: 1n).
  2. Each co-signer signs signingHash = Keccak256(RLP([nonce, chainId, gasPrice, gasCoin, type, dataBytes, payload, serviceData, 0x02])).
  3. Encode outer field #9 (signatureData) as RLP([multisigAddress20B, [[v1, r1, s1], [v2, r2, s2], ...]]).
  4. The Minter protocol does not require lexicographical signature sorting: the node recovers each signer via ecrecover, rejects duplicate signers, matches each recovered address against addresses[], and verifies sum(weights) >= threshold. Ordering signatures[] to match addresses[] is an application convention so independent co-signers produce byte-identical signedRawTxHex and the same Mt... hash.
  5. Off-chain .msig JSON draft files are an external application convention rather than a built-in @minter-network/tx-core format (decodeRawTx decodes complete 10-field signed transactions; to inspect an unsigned draft, pass structured UnsignedTx fields and decode inner data via decodeTxData).
typescript
import {
  MinterGateClient,
  assembleMultisigTx,
  buildCreateMultisigTx,
  buildSendTx,
  deriveMultisigAddress,
  parsePip,
  signTx,
  signTxForMultisig,
} from "@minter-network/tx-core";
import type { MinterWallet } from "@minter-network/tx-core";

// Supply these inputs from your application.
declare const owner1: MinterWallet;
declare const owner2: MinterWallet;
declare const owner3: MinterWallet;

const gate = new MinterGateClient(
  process.env.MINTER_GATE_URL ?? "https://gate.minter.network/v2",
);

// 1. Create a 2-of-3 multisig (weights [400, 400, 600], threshold 800)
const creatorNonce = await gate.getNextNonce(owner1.address);
const createUnsigned = buildCreateMultisigTx(
  {
    threshold: 800,
    weights: [400, 400, 600],
    addresses: [owner1.address, owner2.address, owner3.address],
  },
  { nonce: creatorNonce, chainId: 1, gasCoin: 1993 },
);

const createSigned = signTx(createUnsigned, owner1.privateKey);
await gate.sendTransaction(createSigned.signedRawTxHex);
await gate.waitForTransaction(createSigned.txHash);

const multisigMx = deriveMultisigAddress(owner1.address, creatorNonce);

// 2. First payout from the multisig account (transaction_count = 0 -> nonce = 1n)
const unsignedPayout = buildSendTx(
  {
    coinId: 1993,
    to: "Mx3a7b9104e82d19c64f01b5a8e9c72104d3e811f0",
    valuePip: parsePip("1000"),
  },
  {
    nonce: 1n,
    chainId: 1,
    gasPrice: 1,
    gasCoin: 1993,
    payload: "treasury:payout-Q4",
    signatureType: 2,
  },
);

const sig1 = signTxForMultisig(unsignedPayout, owner1.privateKey);
const sig2 = signTxForMultisig(unsignedPayout, owner2.privateKey);

const { signedRawTxHex, txHash } = assembleMultisigTx(
  unsignedPayout,
  multisigMx,
  [sig1, sig2],
);
await gate.sendTransaction(signedRawTxHex);
await gate.waitForTransaction(txHash);

Hot / Cooler / Cold custody and policy signer

If the only signing key resides on an internet-facing server, a compromised process can drain the treasury. Assigning weights [400, 400, 600] with threshold = 800 splits authority across three keys:

  1. Hot (weight 400) runs inside the application worker or AI agent, builds UnsignedTx, and produces sigHot, which alone cannot reach 800.
  2. Cooler (weight 400) runs on an isolated host with no inbound ports, pulls signing requests from a queue, verifies sigHot via ecrecover, validates chainId, signatureType, gasCoin, opcode, recipient allowlist, and per-coinId caps, and appends sigCooler (400 + 400 = 800).
  3. Cold (weight 600) stays offline and pairs with Cooler (1000 >= 800) to rotate a compromised Hot key via EditMultisig (0x12), or pairs with Hot (1000 >= 800) during Cooler hardware maintenance.
Signer combinationWeight sumNode decision (threshold = 800)Operational role
Hot only400Rejected (< 800)Compromised web worker or agent cannot move funds
Hot + Cooler800Executed (>= 800)Automated payouts within policy limits
Cold + Cooler1000Executed (>= 800)Rotate Hot key via EditMultisig (0x12)
Cold + Hot1000Executed (>= 800)Recovery signing if Cooler host is offline
typescript
import {
  SIGNATURE_TYPE,
  TX_TYPE,
  assembleMultisigTx,
  computeSigningHash,
  decodeTxData,
  parsePip,
  recoverAddressFromVrs,
  signTxForMultisig,
  type EcdsaSignatureVrs,
  type MxAddress,
  type SendTxData,
  type UnsignedTx,
} from "@minter-network/tx-core";

const ALLOWED_GAS_COINS = new Set<number>([0, 1993]);
const ALLOWED_RECIPIENTS = new Set<string>([
  "mx3a7b9104e82d19c64f01b5a8e9c72104d3e811f0",
]);

// Separate per-coinId caps in pip
const MAX_PER_TX_BY_COIN = new Map<number, bigint>([
  [1993, parsePip("250")],     // max 250 USDTE per transaction
  [0, parsePip("50000")],      // max 50,000 BIP per transaction
]);

export function coolerCoSignIfCompliant(params: {
  unsignedTx: UnsignedTx;
  multisigMx: MxAddress;
  expectedHotMx: MxAddress;
  sigHot: EcdsaSignatureVrs;
  coolerPrivateKey: Uint8Array;
}) {
  const { unsignedTx, multisigMx, expectedHotMx, sigHot, coolerPrivateKey } = params;

  if (unsignedTx.chainId !== 1) {
    throw new Error(`Unexpected chainId: ${unsignedTx.chainId}`);
  }
  if (unsignedTx.signatureType !== SIGNATURE_TYPE.MULTISIG) {
    throw new Error(`Expected signatureType 2, got ${unsignedTx.signatureType}`);
  }
  if (ALLOWED_GAS_COINS.has(unsignedTx.gasCoin) === false) {
    throw new Error(`Disallowed gasCoin: ${unsignedTx.gasCoin}`);
  }
  if (unsignedTx.gasPrice !== 1) {
    throw new Error(`Disallowed gasPrice: ${unsignedTx.gasPrice}`);
  }
  if (unsignedTx.payload.length + unsignedTx.serviceData.length > 256) {
    throw new Error("Payload/serviceData exceeds Cooler policy (256 bytes)");
  }

  const signingHash = computeSigningHash(unsignedTx);
  const recoveredHot = recoverAddressFromVrs(signingHash, sigHot);
  if (recoveredHot.toLowerCase() !== expectedHotMx.toLowerCase()) {
    throw new Error(`sigHot signer mismatch: ${recoveredHot}`);
  }

  // Reject EditMultisig (0x12), Unbond (0x08), and all opcodes except Send (0x01)
  if (unsignedTx.type !== TX_TYPE.SEND) {
    throw new Error(`Opcode not permitted by policy: 0x${unsignedTx.type.toString(16)}`);
  }

  const send = decodeTxData(TX_TYPE.SEND, unsignedTx.data) as SendTxData;
  if (ALLOWED_RECIPIENTS.has(send.to.toLowerCase()) === false) {
    throw new Error(`Recipient not in allowlist: ${send.to}`);
  }

  const maxPip = MAX_PER_TX_BY_COIN.get(send.coinId);
  if (maxPip === undefined) {
    throw new Error(`Asset coinId ${send.coinId} is not permitted`);
  }
  if (send.valuePip > maxPip) {
    throw new Error(`Amount ${send.valuePip} pip exceeds cap ${maxPip} pip for coinId ${send.coinId}`);
  }

  const sigCooler = signTxForMultisig(unsignedTx, coolerPrivateKey);
  return assembleMultisigTx(unsignedTx, multisigMx, [sigHot, sigCooler]);
}
Isolated Cooler policy co-signer for 2-of-3 multisig
Using @minter-network/tx-core, implement a TypeScript Cooler service for a Minter v3.3.0 multisig with weights [400, 400, 600] and threshold = 800. Pull signing jobs from NATS, assert chainId === 1, signatureType === 2, and an allowed gasCoin, recover the first signer via computeSigningHash and recoverAddressFromVrs (matching expectedHotMx), reject EditMultisig (0x12) and non-whitelisted opcodes, decode Send (0x01) via decodeTxData, enforce a recipient allowlist and per-coinId single/daily pip caps, verify the current multisig nonce against Gate API v2, and assemble the signed transaction with assembleMultisigTx.