SDKsTypeScript@t402/wdk-multisig

@t402/wdk-multisig

Multi-signature wallet support for T402 payments using Safe (formerly Gnosis Safe).

Installation

pnpm add @t402/wdk-multisig

Overview

The @t402/wdk-multisig package enables T402 payments from Safe multi-signature wallets. It supports:

  • Safe Smart Accounts - Industry-standard multi-sig wallets
  • Threshold Signatures - Configure M-of-N signing requirements
  • Transaction Queuing - Collect signatures before execution
  • EIP-712 Signing - Secure typed data signatures

Multi-sig payments require all required signers to approve before settlement can occur.

Features

FeatureDescription
Safe IntegrationFull Safe SDK integration
Threshold Support1-of-N to N-of-N configurations
Offline SigningCollect signatures asynchronously
Transaction BuilderHelper for creating Safe transactions

Basic Usage

import { SafeMultisigScheme } from '@t402/wdk-multisig'
 
// Initialize with Safe address
const scheme = new SafeMultisigScheme({
  safeAddress: '0xYourSafeAddress...',
  signers: [signer1, signer2], // Array of signers
  threshold: 2, // Required signatures
  rpcUrl: 'https://mainnet.base.org'
})
 
// Create payment requires collecting signatures
const payload = await scheme.createPaymentPayload(2, requirements)

Configuration

interface SafeMultisigConfig {
  safeAddress: string;       // Safe wallet address
  signers: Signer[];         // Array of signers
  threshold: number;         // Required signature count
  rpcUrl: string;           // RPC endpoint
  network?: string;         // CAIP-2 network ID
}

Payment Flow

  1. Initiate - First signer creates the payment request
  2. Collect - Other signers review and sign
  3. Execute - Once threshold reached, transaction is submitted
  4. Settle - Facilitator processes the multi-sig transaction

Supported Networks

Multi-sig payments are supported on all EVM chains where Safe is deployed:

  • Ethereum Mainnet & Sepolia
  • Arbitrum One & Sepolia
  • Base & Base Sepolia
  • Optimism & OP Sepolia
  • Polygon

Example: 2-of-3 Multi-sig

import { SafeMultisigScheme } from '@t402/wdk-multisig'
import { privateKeyToAccount } from 'viem/accounts'
 
// Create signers
const signer1 = privateKeyToAccount('0x...')
const signer2 = privateKeyToAccount('0x...')
const signer3 = privateKeyToAccount('0x...')
 
// Initialize scheme
const scheme = new SafeMultisigScheme({
  safeAddress: '0xYourSafe...',
  signers: [signer1, signer2, signer3],
  threshold: 2,
  rpcUrl: 'https://mainnet.base.org'
})
 
// Create payment (collects 2 signatures)
const requirements = {
  scheme: 'exact',
  network: 'eip155:8453',
  amount: '1000000',
  payTo: '0xRecipient...',
  asset: '0xUSDT0Address...'
}
 
const payload = await scheme.createPaymentPayload(2, requirements)

Security Considerations

  • Always verify Safe ownership before signing
  • Use hardware wallets for production signers
  • Implement proper access controls for signature collection
  • Consider time-locks for high-value transactions