Skip to content

Types

safe_kit.types

SafeAccountConfig

Bases: BaseModel

Configuration for deploying a new Safe.

Source code in safe_kit/types.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class SafeAccountConfig(BaseModel):
    """
    Configuration for deploying a new Safe.
    """

    owners: list[str]
    threshold: int
    to: str = "0x0000000000000000000000000000000000000000"
    data: str = "0x"
    fallback_handler: str = "0x0000000000000000000000000000000000000000"
    payment_token: str = "0x0000000000000000000000000000000000000000"
    payment: int = 0
    payment_receiver: str = "0x0000000000000000000000000000000000000000"

SafeCollectibleResponse

Bases: BaseModel

NFT/Collectible owned by a Safe.

Source code in safe_kit/types.py
201
202
203
204
205
206
207
208
209
210
211
212
213
class SafeCollectibleResponse(BaseModel):
    """NFT/Collectible owned by a Safe."""

    address: str
    token_name: str = Field(alias="tokenName")
    token_symbol: str = Field(alias="tokenSymbol")
    logo_uri: str = Field(alias="logoUri")
    id: str
    uri: str | None
    name: str | None
    description: str | None
    image_uri: str | None = Field(alias="imageUri")
    metadata: dict[str, Any] | None

SafeCreationInfoResponse

Bases: BaseModel

Information about Safe creation.

Source code in safe_kit/types.py
190
191
192
193
194
195
196
197
198
class SafeCreationInfoResponse(BaseModel):
    """Information about Safe creation."""

    created: str
    creator: str
    transaction_hash: str = Field(alias="transactionHash")
    factory_address: str = Field(alias="factoryAddress")
    master_copy: str = Field(alias="masterCopy")
    setup_data: str | None = Field(alias="setupData")

SafeDataDecoderResponse

Bases: BaseModel

Decoded data from the Safe Transaction Service.

Source code in safe_kit/types.py
235
236
237
238
239
class SafeDataDecoderResponse(BaseModel):
    """Decoded data from the Safe Transaction Service."""

    method: str
    parameters: list[dict[str, Any]] | None

SafeDelegateResponse

Bases: BaseModel

Delegate for a Safe.

Source code in safe_kit/types.py
216
217
218
219
220
221
222
class SafeDelegateResponse(BaseModel):
    """Delegate for a Safe."""

    safe: str | None
    delegate: str
    delegator: str
    label: str

SafeInfoResponse

Bases: BaseModel

Information about a Safe from the Transaction Service.

Source code in safe_kit/types.py
176
177
178
179
180
181
182
183
184
185
186
187
class SafeInfoResponse(BaseModel):
    """Information about a Safe from the Transaction Service."""

    address: str
    nonce: int
    threshold: int
    owners: list[str]
    master_copy: str = Field(alias="masterCopy")
    modules: list[str]
    fallback_handler: str = Field(alias="fallbackHandler")
    guard: str
    version: str | None

SafeTokenResponse

Bases: BaseModel

Information about a Token.

Source code in safe_kit/types.py
225
226
227
228
229
230
231
232
class SafeTokenResponse(BaseModel):
    """Information about a Token."""

    address: str
    name: str
    symbol: str
    decimals: int
    logo_uri: str | None = Field(alias="logoUri")

SafeTransaction

Bases: BaseModel

Model representing a complete Safe transaction including signatures.

Source code in safe_kit/types.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
class SafeTransaction(BaseModel):
    """
    Model representing a complete Safe transaction including signatures.
    """

    data: SafeTransactionData
    signatures: dict[str, str] = Field(default_factory=dict)

    def add_signature(self, owner: str, signature: str) -> None:
        self.signatures[owner] = signature

    @property
    def sorted_signatures_bytes(self) -> bytes:
        from hexbytes import HexBytes

        # Sort by owner address
        sorted_owners = sorted(self.signatures.keys(), key=lambda x: int(x, 16))
        signature_bytes = b""
        for owner in sorted_owners:
            signature_bytes += HexBytes(self.signatures[owner])
        return signature_bytes

SafeTransactionData

Bases: BaseModel

Model representing the data of a Safe transaction.

Source code in safe_kit/types.py
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
class SafeTransactionData(BaseModel):
    """
    Model representing the data of a Safe transaction.
    """

    to: str
    value: int
    data: str
    operation: int = 0
    safe_tx_gas: int = 0
    base_gas: int = 0
    gas_price: int = 0
    gas_token: str = "0x0000000000000000000000000000000000000000"
    refund_receiver: str = "0x0000000000000000000000000000000000000000"
    nonce: int | None = None

    model_config = ConfigDict(arbitrary_types_allowed=True)

    def get_eip712_data(self, chain_id: int, safe_address: str) -> dict[str, Any]:
        from hexbytes import HexBytes

        return {
            "types": {
                "EIP712Domain": [
                    {"name": "chainId", "type": "uint256"},
                    {"name": "verifyingContract", "type": "address"},
                ],
                "SafeTx": [
                    {"name": "to", "type": "address"},
                    {"name": "value", "type": "uint256"},
                    {"name": "data", "type": "bytes"},
                    {"name": "operation", "type": "uint8"},
                    {"name": "safeTxGas", "type": "uint256"},
                    {"name": "baseGas", "type": "uint256"},
                    {"name": "gasPrice", "type": "uint256"},
                    {"name": "gasToken", "type": "address"},
                    {"name": "refundReceiver", "type": "address"},
                    {"name": "nonce", "type": "uint256"},
                ],
            },
            "primaryType": "SafeTx",
            "domain": {
                "chainId": chain_id,
                "verifyingContract": safe_address,
            },
            "message": {
                "to": self.to,
                "value": self.value,
                "data": HexBytes(self.data),
                "operation": self.operation,
                "safeTxGas": self.safe_tx_gas,
                "baseGas": self.base_gas,
                "gasPrice": self.gas_price,
                "gasToken": self.gas_token,
                "refundReceiver": self.refund_receiver,
                "nonce": self.nonce if self.nonce is not None else 0,
            },
        }