createSafeClient
Returns an instance of the SafeClient
class, which enables developers to configure new or existing Safe accounts and handle transactions.
The SafeClient
class provides a mechanism to extend its functionality via the extend
method.
Usage
_10import { createSafeClient } from '@safe-global/sdk-starter-kit'_10_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 apiKey: 'YOUR_API_KEY', // Necessary for Safe API interactions_10 txServiceUrl = 'https://...' // Optional. Use it if you run your own service_10})
Use the safeAddress
property to use an existing Safe account.
Returns
Promise<SafeClient>
A new instance of the SafeClient
class.
Parameters
provider
- Type:
Eip1193Provider | HttpTransport | SocketTransport
The provider connected to the blockchain.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 apiKey: 'YOUR_API_KEY'_10})
signer
- Type:
HexAddress | PrivateKey | PasskeyClient
The signer connected to the Safe as an owner.
- If it's an address, the same address from the
provider
will be used to sign. - If it's a private key, its derived address will be used to sign.
- If it's a passkey, the passkey will be used to sign.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 apiKey: 'YOUR_API_KEY'_10})
safeAddress
(Optional)
- Type:
HexAddress
The address of the connected Safe.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 apiKey: 'YOUR_API_KEY'_10})
safeOptions.owners
(Optional)
- Type:
string[]
The list of owners to configure in the Safe.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeOptions: {_10 owners: ['0x...', '0x...', '0x...'],_10 threshold: 2,_10 saltNonce: '123'_10 },_10 apiKey: 'YOUR_API_KEY'_10})
safeOptions.threshold
(Optional)
- Type:
number
The threshold of the Safe. It must be lower or equal to the number of owners.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeOptions: {_10 owners: ['0x...', '0x...', '0x...'],_10 threshold: 2,_10 saltNonce: '123'_10 },_10 apiKey: 'YOUR_API_KEY'_10})
safeOptions.saltNonce
(Optional)
- Type:
string
The salt introduces randomness or predictability when the Safe address is generated.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeOptions: {_10 owners: ['0x...', '0x...', '0x...'],_10 threshold: 2,_10 saltNonce: '123'_10 }_10 apiKey: 'YOUR_API_KEY'_10})
apiKey
(Optional)
- Type:
string
The API key for the Safe Transaction Service. This parameter is mandatory when using default Safe provided services. It can be omitted if using a custom Transaction Service. Check how to get one.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 apiKey: 'YOUR_API_KEY'_10})
txServiceUrl
(Optional)
- Type:
string
The URL of the Safe Transaction Service. This can be provided instead of apiKey
to specify a custom Transaction Service endpoint, such as when running your own Safe Transaction Service instance.
_10const safeClient = await createSafeClient({_10 provider,_10 signer,_10 safeAddress: '0x...',_10 txServiceUrl: 'https://...'_10})