bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 12쪽 중 9쪽
ion: OperationType.Call
_
23
}
_
23
_
23
const safeTransaction = await protocolKitOwner1.createTransaction({
_
23
transactions: [safeTransactionData]
_
23
})
_
23
_
23
const safeTxHash = await protocolKitOwner1.getTransactionHash(safeTransaction)
_
23
const signature = await protocolKitOwner1.signHash(safeTxHash)
_
23
_
23
// Propose transaction to the service
_
23
await apiKit.proposeTransaction({
_
23
safeAddress: SAFE_ADDRESS,
_
23
safeTransactionData: safeTransaction.data,
_
23
safeTxHash,
_
23
senderAddress: OWNER_1_ADDRESS,
_
23
senderSignature: signature.data
_
23
})
Retrieve the pending transactions
Different methods in the API Kit are available to retrieve pending transactions depending on the situation. To retrieve a transaction given the Safe transaction hash use the method that's not commented.
_
10
const transaction = await service.getTransaction(safeTxHash)
_
10
// const transactions = await service.getPendingTransactions()
_
10
// const transactions = await service.getIncomingTransactions()
_
10
// const transactions = await service.getMultisigTransactions()
_
10
// const transactions = await service.getModuleTransactions()
_
10
// const transactions = await service.getAllTransactions()
Confirm the transaction
In this step you need to sign the transaction with the Protocol Kit and submit the signature to the Safe Transaction Service using the
confirmTransaction
method.
_
14
const protocolKitOwner2 = await Safe.init({
_
14
provider: RPC_URL,
_
14
signer: OWNER_2_PRIVATE_KEY,
_
14
safeAddress: SAFE_ADDRESS
_
14
})
_
14
_
14
const safeTxHash = transaction.transactionHash
_
14
const signature = await protocolKitOwner2.signHash(safeTxHash)
_
14
_
14
// Confirm the Safe transaction
_
14
const signatureResponse = await apiKit.confirmTransaction(
_
14
safeTxHash,
_
14
signature.data
_
14
)
The Safe transaction is now ready to be executed. This can be done using the
Safe{Wallet} web
(opens in a new tab)
interface, the
Protocol Kit
, the
Safe CLI
or any other tool that's available.
API Kit
Migrate to v1
Was this page helpful?
Report issue
## /sdk/api-kit/guides/migrate-to-v1
SDK
API Kit
Guides
Migrate to v1
Migrate to v1
This guide references the major changes between
safe-service-client
and
api-kit
v1 to help those migrating an existing application.
Note:
Follow this guide before migrating to
api-kit
v2.
After completing this guide, you can remove
@safe-global/safe-service-client
from your
package.json
.
Adding the new dependency
To add the API Kit to your project, run the following:
_
10
yarn add @safe-global/api-kit@1.3.1
Change your initialization like this:
_
15
// old
_
15
import SafeServiceClient from '@safe-global/safe-service-client'
_
15
_
15
const safeService = new SafeServiceClient({
_
15
txServiceUrl: 'https://your-transaction-service-url',
_
15
ethAdapter
_
15
})
_
15
_
15
// new
_
15
import SafeApiKit from '@safe-global/api-kit'
_
15
_
15
const apiKit = new SafeApiKit({
_
15
txServiceUrl: 'https://your-transaction-service-url',
_
15
ethAdapter
_
15
})
getSafeDelegates()
The
getSafeDelegates
was updated to accept more filtering parameters. Now, it accepts an object with multiple properties instead of only the
safeAddress
parameter.
_
10
const delegateConfig: GetSafeDelegateProps = {
_
10
safeAddress, // Optional
_
10
delegateAddress, // Optional
_
10
delegatorAddress, // Optional
_
10
label, // Optional
_
10
limit, // Optional
_
10
offset // Optional
_
10
}
_
10
const delegates: SafeDelegateListResponse = await apiKit.getSafeDelegates(delegateConfig)
addSafeDelegate()
Parameter object properties were updated as follows:
_
18
// old
_
18
const delegateConfig: SafeDelegateConfig = {
_
18
safe,
_
18
delegate,
_
18
label,
_
18
signer
_
18
}
_
18
await safeService.addSafeDelegate(delegateConfig)
_
18
_
18
// new
_
18
const delegateConfig: AddSafeDelegateProps = {
_
18
safeAddress, // Optional
_
18
delegateAddress,
_
18
delegatorAddress,
_
18
label,
_
18
signer
_
18
}
_
18
await apiKit.addSafeDelegate(delegateConfig)
removeAllSafeDelegates()
The method was deprecated and removed.
removeSafeDelegate()
Parameter object properties were updated as follows:
_
15
// old
_
15
const delegateConfig: SafeDelegateDeleteConfig = {
_
15
safe,
_
15
delegate,
_
15
signer
_
15
}
_
15
await safeService.removeSafeDelegate(delegateConfig)
_
15
_
15
// new
_
15
const delegateConfig: DeleteSafeDelegateProps = {
_
15
delegateAddress,
_
15
delegatorAddress,
_
15
signer
_
15
}
_
15
await apiKit.removeSafeDelegate(delegateConfig)
getBalances()
The method was deprecated and removed.
getUSDBalances()
The method was deprecated and removed.
getCollectibles()
The method was deprecated and removed.
Propose and Confirm Transactions
Migrate to v2
Was this page helpful?
Report issue
## /sdk/api-kit/guides/migrate-to-v2
SDK
API Kit
Guides
Migrate to v2
Migrate to v2
This guide references the major changes between v1 and v2 to help those migrating an existing app.
API Kit constructor
It won't be necessary to specify a
txServiceUrl
in environments where Safe has a Transaction Service running. Providing the chain ID will be enough. If you want to use your custom service or the kit in a chain not supported by a Safe Transaction Service, you can add the
txServiceUrl
parameter.
_
21
// old:
_
21
import SafeApiKit from '@safe-global/api-kit'
_
21
_
21
const apiKit = new SafeApiKit({
_
21
txServiceUrl: 'https://your-transaction-service-url',
_
21
ethAdapter
_
21
})
_
21
_
21
// new:
_
21
import SafeApiKit from '@safe-global/api-kit'
_
21
_
21
const chainId: bigint = 1n
_
21
const apiKit = new SafeApiKit({
_
21
chainId
_
21
})
_
21
_
21
// or set a custom Transaction Service
_
21
const apiKit = new SafeApiKit({
_
21
chainId,
_
21
txServiceUrl: 'https://your-transaction-service-url'
_
21
})
Use the route you prefer
API Kit v1 forced any custom service to be hosted under the
/api
route of the URL specified in
txServiceUrl
. This isn't the case anymore; you can specify any preferred route or subdomain.
Note that if you use a custom service running under
/api
, you will now need to migrate as follows:
_
13
// old:
_
13
const txServiceUrl = 'https://your-transaction-service-domain/'
_
13
const apiKit = new SafeApiKit({
_
13
txServiceUrl,
_
13
ethAdapter
_
13
})
_
13
// new:
_
13
const chainId: bigint = 1n
_
13
const txServiceUrl = 'https://your-transaction-service-domain/api'
_
13
const apiKit = new SafeApiKit({
_
13
chainId,
_
13
txServiceUrl
_
13
})
Mastercopy to Singleton
To avoid confusion between terms used as synonyms, we aligned all our code to use the word
singleton
.
Rename type
MasterCopyResponse
to
SafeSingletonResponse
Rename method
getServiceMasterCopiesInfo()
to
getServiceSingletonsInfo()
Migrate to v1
Migrate to v3
Was this page helpful?
Report issue
## /sdk/api-kit/guides/migrate-to-v3
SDK
API Kit
Guides
Migrate to v3
Migrate to v3
This guide references the major changes between v2 and v3 to help those migrating an existing app.
Changed method signature
We extracted
safeAddress
and renamed
xxxProps
types to
xxxOptions
types in the following method
getSafeOperationsByAddress(props: GetSafeOperationListProps)
is now
getSafeOperationsBySafeAddress(safeAddress, options: GetSafeOperationListOptions)
Renamed types
We renamed the
xxxProps
types to
xxxOptions
in the following methods:
addMessage(safeAddress: string, addMessageProps: AddMessageProps)
is now
addMessage(safeAddress: string, addMessageOptions: AddMessageOptions)
getMessages(safeAddress: string, props: GetSafeMessageListProps)
is now
getMessages(safeAddress: string, options: GetSafeMessageListOptions)
Migrate to v2
Migrate to v4
Was this page helpful?
Report issue
## /sdk/api-kit/guides/migrate-to-v4
SDK
API Kit
Guides
Migrate to v4
Migrate to v4
This guide references the major changes between v3 and v4 to help those migrating an existing app.
Use API key for default services
Public unauthenticated endpoints will be deprecated. A new
apiKey
parameter was added to the constructor so you can set your API key when running on Safe default services.
Follow
our guide
to get an API key.
Once you get your API key, simply pass it to the constructor:
_
16
// old:
_
16
import SafeApiKit from '@safe-global/api-kit'
_
16
_
16
const chainId: bigint = 1n
_
16
const apiKit = new SafeApiKit({
_
16
chainId
_
16
})
_
16
_
16
//new:
_
16
import SafeApiKit from '@safe-global/api-kit'
_
16
_
16
const chainId: bigint = 1n
_
16
const apiKit = new SafeApiKit({
_
16
chainId,
_
16
apiKey: 'YOUR_API_KEY'
_
16
})
Updated type
Endpoints returning
SafeMultisigTransactionListResponse
or types based in this one, have been updated to use the latest version. The following methods are affected:
getTransaction()
getMultisigTransactions()
getPendingTransactions()
getAllTransactions()
proposeTransaction()
You can expect the following type changes:
nonce
: from
number
to
string
safeTxGas
: from
number
to
string
baseGas
: from
number
to
string
Migrate to v3
Reference
Was this page helpful?
Report issue
## /reference-sdk-api-kit/overview
API Kit Reference
Overview
API Kit Reference
The
API Kit
facilitates the interaction with the
Safe Transaction Service API
.
Install dependencies
To add the API Kit to your project, run:
pnpm
npm
yarn
_
10
pnpm add @safe-global/api-kit
← Go Back
constructor
Was this page helpful?
Report issue
## /sdk/relay-kit
SDK
Relay Kit
Relay Kit
The Relay Kit enables transaction relaying with Safe, and allows users to pay for the transaction fees from their Safe account using the blockchain native token, ERC-20 tokens, or to get their transactions sponsored.
⚠️
Relaying transactions through Gelato isn't supported from September 1, 2026. Use the
ERC-4337 Safe accounts guide
instead. See the
Gelato Relay guide
for migration details.
@safe-global/relay-kit
The following guides show how to use the Relay Kit and integrate it into your project by using one of the packs:
Integrate ERC-4337 Safe accounts
Integrate Gelato Relay
(deprecated)
Resources
Relay Kit on GitHub
(opens in a new tab)
Reference
ERC-4337 Safe SDK
Was this page helpful?
Report issue
## /sdk/relay-kit/guides/4337-safe-sdk
SDK
Relay Kit
Guides
ERC-4337 Safe SDK
Safe accounts with the Safe4337Module
In this guide, you will learn how to create and execute multiple Safe transactions grouped in a batch from a Safe account that is not yet deployed and where the executor may or may not have funds to pay for the transaction fees. This can be achieved by supporting the
ERC-4337
execution flow, which is supported by the
Safe4337Module
and exposed via the Relay Kit from the Safe{Core} SDK.
Read the
Safe4337Module documentation
to understand its benefits and flows better.
Pimlico
(opens in a new tab)
is used in this guide as the service provider, but any other provider compatible with the ERC-4337 can be used.
ℹ️
We have added support for then Entrypoint v0.7 contract but we are not making it the default yet.
If you are using Entrypoint v0.7, you need to set the
safeModuleVersion
to
0.3.0
when calling the
Safe4337Pack.init
method. This version of the Safe 4337 Module is the one compatible with the Entrypoint v0.7.
Prerequisites
Node.js and npm
(opens in a new tab)
.
A
Pimlico account
(opens in a new tab)
and an API key.
Install dependencies
_
10
yarn add @safe-global/relay-kit
Steps
Imports
Here are all the necessary imports for the script we implement in this guide.
_
10
import { Safe4337Pack } from '@safe-global/relay-kit'
Create a signer
Firstly, we need to get a signer, which will be the owner of a Safe account after it's deployed.
In this example, we use a private key, but any way to get an EIP-1193 compatible signer can be used.
_
10
const SIGNER_ADDRESS = // ...
_
10
const SIGNER_PRIVATE_KEY = // ...
_
10
const RPC_URL = 'https://rpc.ankr.com/eth_sepolia'
Initialize the
Safe4337Pack
The
Safe4337Pack
class is exported from the Relay Kit and implements the ERC-4337 to create, sign, and submit Safe user operations.
To instantiate this class, the static
init()
method allows connecting existing Safe accounts (as long as they have the
Safe4337Module
enabled) or setting a custom configuration to deploy a new Safe account at the time where the first Safe transaction is submitted.
New Safe account
Existing Safe account
When deploying a new Safe account, we need to pass the configuration of the Safe in the
options
property. In this case, we are configuring a Safe account that will have our signer as the only owner.
Optionally, you can
track your ERC-4337 Safe transactions on-chain
by using the
onchainAnalytics
property.
By default
Safe4337Pack
is using version
0.2.0
of the Safe 4337 Module that is only compatible with Entrypoint v0.6. If you need to use v0.7 then add the
safeModulesVersion
property to the options object with the '0.3.0' value.
_
12
const safe4337Pack = await Safe4337Pack.init({
_
12
provider: RPC_URL,
_
12
signer: SIGNER_PRIVATE_KEY,
_
12
bundlerUrl: `https://api.pimlico.io/v2/11155111/rpc?add_balance_override&apikey=${PIMLICO_API_KEY}`,
_
12
// safeModulesVersion: '0.3.0', // Defaults to 0.2.0. If you are using the v0.7 of the EntryPoint set the value to '0.3.0'
_
12
options: {
_
12
owners: [SIGNER_ADDRESS],
_
12
threshold: 1
_
12
},
_
12
onchainAnalytics // Optional
_
12
// ...
_
12
})
By default, the transaction fees will be paid in the native token and extracted from the Safe account, so there must be enough funds in the Safe address.
You can also use a paymaster to handle the fees. If you choose to use a paymaster, there are two other ways to initialize the
Safe4337Pack
.
Using an ERC-20 Paymaster
Using a verifying Paymaster (Sponsored)
A paymaster will execute the transactions and get reimbursed from the Safe account, which must have enough funds in the Safe address in advance.
Payment of transaction fees is made using an ERC-20 token specified with the
paymasterTokenAddress
property. If an ERC-20 token is used, the Safe must approve that token to the paymaster. If no balance is approved, it can be specified using the
amountToApprove
property.
_
10
const safe4337Pack = await Safe4337Pack.init({
_
10
// ...
_
10
paymasterOptions: {
_
10
paymasterUrl: `https://api.pimlico.io/v2/11155111/rpc?apikey=${PIMLICO_API_KEY}`,
_
10
paymasterAddress: '0x...',
_
10
paymasterTokenAddress: '0x...',
_
10
amountToApprove // Optional
_
10
}
_
10
})
Create a user operation
To create a Safe user operation, use the
createTransaction()
method, which takes the array of transactions to execute and returns a
SafeOperation
object.
_
10
// Define the transactions to execute
_
10
const transaction1 = { to, data, value }
_
10
const transaction2 = { to, data, value }
_
10
_
10
// Build the transaction array
_
10
const transactions = [transaction1, transaction2]
_
10
_
10
// Create the SafeOperation with all the transactions
_
10
const safeOperation = await safe4337Pack.createTransaction({ transactions })
The
safeOperation
object has the
data
and
signatures
properties, which contain all the information about the transaction batch and the signatures of the Safe owners, respectively.
Sign the user operation
Before sending the user operation to the bundler, it's required to sign the
safeOperation
object with the connected signer. The
signSafeOperation()
method, which receives a
SafeOperation
object, generates a signature that will be checked when the
Safe4337Module
validates the user operation.
_
10
const signedSafeOperation = await safe4337Pack.signSafeOperation(identifiedSafeOperation)
Submit the user operation
Once the
safeOperation
object is signed, we can call the
executeTransaction()
method to submit the user operation to the bundler.
_
10
const userOperationHash = await safe4337Pack.executeTransaction({
_
10
executable: signedSafeOperation
_
10
})
This method returns the hash of the user operation. With it, we can monitor the transaction status using a block explorer or the bundler's API.
Check the transaction status
To check the transaction status, we can use the
getTransactionReceipt()
method, which returns the transaction receipt after it's executed.
_
10
let userOperationReceipt = null
_
10
_
10
while (!userOperationReceipt) {
_
10
// Wait 2 seconds before checking the status again
_
10
await new Promise((resolve) => setTimeout(resolve, 2000))
_
10
userOperationReceipt = await safe4337Pack.getUserOperationReceipt(
_
10
userOperationHash
_
10
)
_
10
}
In addition, we can use the
getUserOperationByHash()
method with the returned hash to retrieve the user operation object we sent to the bundler.
_
10
const userOperationPayload = await safe4337Pack.getUserOperationByHash(
_
10
userOperationHash
_
10
)
Recap and further reading
After following this guide, we are able to deploy new Safe accounts and create, sign, and execute Safe transactions in a batch without the executor needing to have funds to pay for the transaction fees.
Learn more about the ERC-4337 standard and the
Safe4337Module
contract following these links:
ERC-4337 website
(opens in a new tab)
EIP-4337 on Ethereum EIPs
(opens in a new tab)
Safe4337Module on GitHub
(opens in a new tab)
[Safe On-chain Identifiers on GitHub](
https://github.com/5afe/safe-onchain-identifiers
(opens in a new tab)
showcases where and how to add the identifier at the end of your Safe transactions data if you are not using the Relay Kit. Check also the
specific code
(opens in a new tab)
where the identifier is concatenated to the
callData
.
Relay Kit
Gelato Relay (deprecated)
Was this page helpful?
Report issue
## /sdk/relay-kit/guides/gelato-relay
SDK
Relay Kit
Guides
Gelato Relay (deprecated)
Integration with Gelato (deprecated)
⚠️
Relaying transactions through Gelato is no longer supported.
From
September 1, 2026
, transactions can't be relayed through Gelato using
the Relay Kit. This affects the
GelatoRelayPack
, including both the Gelato
1Balance and the Gelato SyncFee flows.
If your integration relies on the
GelatoRelayPack
, migrate to the
ERC-4337 Safe SDK guide
, which uses the
Safe4337Pack
to sponsor transactions or pay fees in ERC-20 tokens through a paymaster.
What changed
The Relay Kit previously shipped two ways to relay a Safe transaction through
Gelato:
Gelato 1Balance
, which sponsored transactions from a prepaid deposit.
Gelato SyncFee
, which paid the gas fees directly with funds held in the
Safe account.
Neither flow is supported anymore. The code examples previously published on
this page have been removed so they aren't copied into new integrations.
What to use instead
The
Safe4337Pack
covers the same use cases through the
ERC-4337 standard:
Previous Gelato flow
ERC-4337 equivalent
1Balance (sponsored transactions)
A verifying paymaster configured with
paymasterOptions
SyncFee (pay fees from the Safe balance)
An ERC-20 paymaster configured with
paymasterOptions
See the
ERC-4337 Safe SDK guide
for a complete example,
and the
Safe4337Pack
reference
for the full
API.
Differences
The ERC-4337 flow covers the same use cases, but is not a drop-in substitute.
Before you start rewriting note these differences:
No cross-chain sponsoring:
With the Gelato flow you could sponsor
cross-chain, using a deposit on one chain sponsoring a transaction on
another. This feature is not available on the ERC-4337 flow. You have
to fund the paymaster per chain.
Chain Availability:
The ERC-4337 module is deployed on a different
chain set than the previous flow. On chains where it is not deployed,
init()
will throw. The
official module deployments
(opens in a new tab)
lists the chains where it is deployed.
Safe ≥ v1.4.1:
The ERC-4337 flow is supported for Safe v1.4.1
and higher.
Resources
ERC-4337 Safe SDK guide
Safe4337Pack reference
Relay Kit on GitH프로젝트로 돌아가기