connect
Returns a new instance of the Protocol Kit connected to a new Safe or a new signer.
Usage
Depending on whether the Safe account you want to connect to the Protocol Kit is deployed or not, you can do it in two different ways:
Connection of a deployed Safe using the safeAddress
property:
_10import Safe from '@safe-global/protocol-kit'_10_10const protocolKit = Safe.init({_10 // ..._10})_10_10const newProtocolKit = await protocolKit.connect({_10 signer, // Optional_10 safeAddress: '0x...' // Optional_10})
Parameters
provider
(Optional)
- Type:
Eip1193Provider
(opens in a new tab) |HttpTransport
(opens in a new tab) |SocketTransport
(opens in a new tab)
An EIP-1193 (opens in a new tab) compatible provider, or an RPC URL.
_10const protocolKit = await Safe.connect({_10 provider: 'https://eth-sepolia.public.blastapi.io',_10 signer,_10 safeAddress: '0x...'_10})
signer
(Optional)
- Type:
string
|PasskeyArgType
(opens in a new tab) |PasskeyClient
(opens in a new tab)
A Safe owner address, its private key, or a passkey object.
_10const protocolKit = await Safe.connect({_10 provider,_10 signer: '0x...',_10 safeAddress: '0x...'_10})
safeAddress
(Optional)
- Type:
string
The address of a Safe account.
Use this property to connect a Safe account that is already deployed to the Protocol Kit instance.
_10const protocolKit = await Safe.connect({_10 provider,_10 signer,_10 safeAddress: '0x...'_10})
predictedSafe
(Optional)
An object that contains the Safe account configuration and deployment details.
Use this property to connect a Safe account that has yet to be deployed the Protocol Kit instance. This object contains the following properties:
safeAccountConfig
:owners
: An array of Safe owner addresses.threshold
: The number of signatures required to execute a Safe transaction.to
(optional): The contract address for optional delegate call.data
(optional): The data payload for optional delegate call.fallbackHandler
(optional): The fallback handler address.paymentToken
(optional): The token that should be used for the payment (use0x0000000000000000000000000000000000000000
for the native token).payment
(optional): The value that should be paid.paymentReceiver
(optional): The address that should receive the payment (use0x0000000000000000000000000000000000000000
for thetx.origin
).
safeDeploymentConfig
:saltNonce
(optional): The salt nonce to use. Changing this value will update the predicted Safe account address.safeVersion
(optional): The Safe contract version to use.deploymentType
(optional): The Safe deployment type to use. It can becanonical
,eip155
, orzksync
. Changing this value affects the search algorithm used to find the Safe deployment address (opens in a new tab) for any Safe contract, resulting in a change to the predicted address.
_10const protocolKit = await Safe.connect({_10 provider,_10 signer,_10 predictedSafe_10})
isL1SafeSingleton
(Optional)
- Type:
boolean
A boolean variables that indicates if the Safe uses the Safe.sol
(opens in a new tab) contract as the singleton contract (true
), or uses the SafeL2.sol
(opens in a new tab) contract instead (false
).
Safe.sol
version of the contract doesn't trigger events for each Safe transaction to save gas. SafeL2.sol
version triggers events, which is more appropriate for L2 networks.
By default, Safe.sol
is only used on Ethereum Mainnet. For the rest of the networks where the Safe contracts are already deployed, the SafeL2.sol
contract is used unless you add the isL1SafeSingleton
flag to force using the Safe.sol
contract.
_10const protocolKit = await Safe.connect({_10 provider,_10 signer,_10 safeAddress,_10 isL1SafeSingleton: true_10})
contractNetworks
(Optional)
If the Safe contracts aren't deployed to your current network, this property is required to point to the addresses of the Safe contracts previously deployed by you.
_27const protocolKit = await Safe.connect({_27 provider,_27 signer,_27 safeAddress,_27 contractNetworks: {_27 [chainId]: {_27 safeSingletonAddress: '<SINGLETON_ADDRESS>',_27 safeProxyFactoryAddress: '<PROXY_FACTORY_ADDRESS>',_27 multiSendAddress: '<MULTI_SEND_ADDRESS>',_27 multiSendCallOnlyAddress: '<MULTI_SEND_CALL_ONLY_ADDRESS>',_27 fallbackHandlerAddress: '<FALLBACK_HANDLER_ADDRESS>',_27 signMessageLibAddress: '<SIGN_MESSAGE_LIB_ADDRESS>',_27 createCallAddress: '<CREATE_CALL_ADDRESS>',_27 simulateTxAccessorAddress: '<SIMULATE_TX_ACCESSOR_ADDRESS>',_27 safeWebAuthnSignerFactoryAddress:'<SAFE_WEB_AUTHN_SIGNER_FACTORY_ADDRESS>',_27 safeSingletonAbi: '<SINGLETON_ABI>', // Optional. Only needed with web3.js_27 safeProxyFactoryAbi: '<PROXY_FACTORY_ABI>', // Optional. Only needed with web3.js_27 multiSendAbi: '<MULTI_SEND_ABI>', // Optional. Only needed with web3.js_27 multiSendCallOnlyAbi: '<MULTI_SEND_CALL_ONLY_ABI>', // Optional. Only needed with web3.js_27 fallbackHandlerAbi: '<FALLBACK_HANDLER_ABI>', // Optional. Only needed with web3.js_27 signMessageLibAbi: '<SIGN_MESSAGE_LIB_ABI>', // Optional. Only needed with web3.js_27 createCallAbi: '<CREATE_CALL_ABI>', // Optional. Only needed with web3.js_27 simulateTxAccessorAbi: '<SIMULATE_TX_ACCESSOR_ABI>' // Optional. Only needed with web3.js_27 safeWebAuthnSignerFactoryAbi: '<SAFE_WEB_AUTHN_SIGNER_FACTORY_ABI>' // Optional. Only needed with web3.js_27 }_27 }_27})
Returns
Promise<Safe>
An instance of the Protocol Kit