Safe
safe_kit.safe
Safe
Bases: SafeInfoMixin, SafeCacheMixin, SafeTransactionsMixin, SafeMessagesMixin, OwnerManagerMixin, ModuleManagerMixin, TokenManagerMixin, GuardManagerMixin
The main class for interacting with a Safe.
This class provides a comprehensive interface for Safe operations including: - Basic Safe info (address, version, balance, nonce, threshold, owners) - Transaction creation, signing, and execution - Owner management (add, remove, swap owners, change threshold) - Module management (enable, disable, list modules) - Token transfers (ERC20, ERC721, native ETH) - Guard and fallback handler management
Source code in safe_kit/safe.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
connect(rpc_url, private_key, safe_address, chain_id=None)
classmethod
Convenience method to connect to a Safe with minimal configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rpc_url
|
str
|
The RPC URL of the Ethereum node. |
required |
private_key
|
str
|
The private key of the signer (with or without 0x prefix). |
required |
safe_address
|
str
|
The address of the Safe contract. |
required |
chain_id
|
int | None
|
Optional chain ID for validation. |
None
|
Returns:
| Type | Description |
|---|---|
Safe
|
A Safe instance connected to the specified Safe contract. |
Example
safe = Safe.connect( rpc_url="https://mainnet.infura.io/v3/...", private_key="0x...", safe_address="0x..." )
Source code in safe_kit/safe.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
create(eth_adapter, safe_address, chain_id=None)
classmethod
Factory method to create a Safe instance.
Source code in safe_kit/safe.py
66 67 68 69 70 71 72 73 | |