Multichain Safe Deployment
This guide will teach you how to replicate a Safe address across different chains using the Protocol Kit. This process includes initializing the Protocol Kit, configuring the Safes to deploy, predicting its address on different chains, and executing the deployment transactions.
For more detailed information, see the Protocol Kit Reference.
Prerequisites
Install dependencies
First, you need to install the Protocol Kit.
Steps
Imports
Here are all the necessary imports for this guide.
Create a signer
You need a signer to instantiate the Protocol Kit. This example uses a private key to obtain a signer, but other EIP-1193 (opens in a new tab) compatible signers are also supported. For detailed information about signers, please refer to the Protocol Kit reference.
Configure the Safe deployment
Define the predictedSafe
object with the configuration for all the Safe accounts you will deploy. Check the reference to learn about all the different configuration options.
Initialize the Protocol Kit
Initialize an instance of the Protocol Kit for each network where you want to deploy a new Safe smart account by calling the init
method. Pass the provider
with its corresponding value depending on the network, the signer
executing the deployment, and the predictedSafe
with the Safe account configuration.
Optionally, you can track your Safe deployments and transactions on-chain by using the onchainAnalytics
property.
Predict the Safe addresses
You can predict the Safe addresses by calling the getAddress
method from each Protocol Kit instance and ensure that the result addresses are the same.
Deployment on Sepolia
Create the deployment transaction to deploy a new Safe account in Sepolia by calling the createSafeDeploymentTransaction
method.
Call the sendTransaction
method from your Sepolia client instance and wait for the transaction to be executed.
Once the deployment transaction is executed, connect the new Safe address to the Protocol Kit instance by calling the connect
method.
If everything went well, isSepoliaSafeDeployed
should be true
, and the sepoliaDeployedSafeAddress
should equal the sepoliaPredictedSafeAddress
.
Deployment on Chiado
Repeat the same steps to deploy a Safe with the same configuration on Chiado testnet.
If everything went well, isChiadoSafeDeployed
should be true
, and the chiadoDeployedSafeAddress
should equal the chiadoPredictedSafeAddress
.
In addition, chiadoDeployedSafeAddress
and sepoliaDeployedSafeAddress
should have the same value.
Recap and further reading
After following this guide, you are able to deploy multiple Safe accounts with the same address on different chains using the Protocol Kit.