Safe Protocol Kit

entity
safesdktypescriptprotocol-kitmultisigsmart-accounts

The Safe Protocol Kit is the official TypeScript SDK for interacting with Safe smart contract accounts. Published as @safe-global/protocol-kit on npm, it wraps the low-level Safe contract ABI into a high-level API for creating and managing Safes, constructing transactions, signing transactions and messages, and validating signatures. It is maintained by the Safe{Core} team as part of the Safe{Core} SDK suite.

Position in the SDK stack

The Safe{Core} SDK is split into several packages that compose:

  • @safe-global/protocol-kit — Safe account lifecycle, transaction and message construction, signing, validation. Direct contract interaction.
  • @safe-global/api-kit — client for the Safe Transaction Service, which stores proposed and partially-signed transactions and messages off-chain.
  • @safe-global/relay-kit — gasless and sponsored transaction execution through relayers.
  • @safe-global/types-kit — shared TypeScript types.

The Protocol Kit is the foundation layer. The other kits depend on it or complement it but do not replace it.

Core responsibilities

The Protocol Kit covers:

  • Deploying new SafescreateSafeDeploymentTransaction, predictSafeAddress, and the SafeFactory flow.
  • Connecting to existing SafesprotocolKit.connect({ provider, signer, safeAddress }).
  • Constructing transactionscreateTransaction, createRejectionTransaction, batch transactions.
  • Signing transactionssignTransaction with SigningMethod selection across ECDSA, typed data, and nested Safe contract signatures.
  • Executing transactionsexecuteTransaction once the threshold is reached.
  • Message signingcreateMessage, signMessage, getSafeMessageHash, isValidSignature. See Safe Protocol Kit Message Signatures for the full flow.
  • Contract utilitiesgetSignMessageLibContract, hashSafeMessage, buildSignatureBytes, buildContractSignature.

Key abstractions

  • EthSafeMessage — a mutable container for a message plus its accumulating owner signatures. Mirrors EthSafeTransaction.
  • EthSafeTransaction — a mutable container for a Safe transaction plus its accumulating owner signatures.
  • Safe SigningMethod — the enum that selects between ETH_SIGN, ETH_SIGN_TYPED_DATA_V4, and SAFE_SIGNATURE (for nested-Safe contract signatures).
  • SafeSignature — an owner’s contribution to a transaction or message, carrying the signer address, signature bytes, and a flag marking whether it is a contract signature.

Adapters

The Protocol Kit is provider-agnostic. It connects through an EthAdapter interface that has implementations for ethers v5, ethers v6, and viem. The same high-level API calls work regardless of which Ethereum library the host application uses.

import Safe from '@safe-global/protocol-kit'

const protocolKit = await Safe.init({
  provider: RPC_URL,
  signer: OWNER_PRIVATE_KEY,
  safeAddress: SAFE_ADDRESS
})

What it does not do

  • It does not store messages or signatures anywhere off-chain — that is the API Kit’s job, backed by the Safe Transaction Service.
  • It does not relay transactions — that is the Relay Kit’s job.
  • It does not provide a UI — that is Safe{Wallet} (app.safe.global).

The Protocol Kit’s scope is specifically the boundary between a host application and the Safe contracts. Everything it does eventually reduces to a contract read (via eth_call) or a transaction (via eth_sendTransaction or delegation to a wallet).

Connections