Safe Protocol Kit
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 Safes —
createSafeDeploymentTransaction,predictSafeAddress, and theSafeFactoryflow. - Connecting to existing Safes —
protocolKit.connect({ provider, signer, safeAddress }). - Constructing transactions —
createTransaction,createRejectionTransaction, batch transactions. - Signing transactions —
signTransactionwithSigningMethodselection across ECDSA, typed data, and nested Safe contract signatures. - Executing transactions —
executeTransactiononce the threshold is reached. - Message signing —
createMessage,signMessage,getSafeMessageHash,isValidSignature. See Safe Protocol Kit Message Signatures for the full flow. - Contract utilities —
getSignMessageLibContract,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, andSAFE_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
- Safe Protocol Kit Message Signatures: the end-to-end message signing flow
- EthSafeMessage: the message signature accumulator
- Safe SigningMethod: the signing-method enum
- Safe Nested Contract Signatures: the recursive pattern for Safes owned by Safes
- SignMessageLib: the delegatecall target the SDK uses for on-chain pre-approvals
- Safe Transaction Service: the off-chain backend the API Kit talks to
- EIP-712: the hashing standard the SDK produces signatures over
- EIP-1271: the validation standard the SDK calls through for contract signers