- class ape_safe.accounts.SafeAccount(*, account_file_path: Path)
- property address: Annotated[ChecksumAddress, _AddressValidator]
The address of this account. Subclasses must override and provide this value.
- property alias: str
A shortened-name for quicker access to the account.
- call(txn: TransactionAPI, impersonate: bool = False, **call_kwargs) ReceiptAPI
Make a transaction call.
- Raises:
AccountsError – When the nonce is invalid or the sender does not have enough funds.
TransactionError – When the required confirmations are negative.
SignatureError – When the user does not sign the transaction.
APINotImplementedError – When setting
private=True
and using a provider that does not support private transactions.
- Parameters:
txn (
TransactionAPI
) – An invoke-transaction.send_everything (bool) –
True
will send the difference from balance and fee. Defaults toFalse
.private (bool) –
True
will use thesend_private_transaction()
method.sign (bool) –
False
to not sign the transaction (useful for providers like Titanoboa which still use a sender but don’t need to sign).**signer_options – Additional kwargs given to the signer to modify the signing operation.
- Returns:
ReceiptAPI
- compute_prev_signer(signer: str | Annotated[ChecksumAddress, _AddressValidator] | BaseAddress) Annotated[ChecksumAddress, _AddressValidator]
Sometimes it’s handy to have “previous owner” for ownership change operations, this function makes it easy to calculate.
- create_safe_tx(txn: TransactionAPI | None = None, **safe_tx_kwargs) SafeTxV1 | SafeTxV2
Create the Safe transaction.
- Parameters:
txn (Optional[
TransactionAPI
]) – The transaction**safe_tx_kwargs – The safe transactions specifications, such as
submitter
.
- Returns:
The Safe Transaction to be used.
- Return type:
SafeTx
- property new_nonce
The next unused nonce in the system. This is different than
.next_nonce
because it includes all nonces the transaction service is aware of and not just the next on-chain nonce.
- property next_nonce: int
The next nonce for on-chain. If you have multiple transactions are in the queue but not published on chain, the next nonce refers to the earliest nonce in that queue.
- prepare_transaction(txn: TransactionAPI) TransactionAPI
Set default values on a transaction.
- Raises:
AccountsError – When the account cannot afford the transaction or the nonce is invalid.
TransactionError – When given negative required confirmations.
- Parameters:
txn (
TransactionAPI
) – The transaction to prepare.**kwargs – Sub-classes, such as
AccountAPI
, use additional kwargs.
- Returns:
TransactionAPI
- propose(txn: TransactionAPI | None = None, submitter: AccountAPI | Annotated[ChecksumAddress, _AddressValidator] | str | None = None, **safe_tx_kwargs) SafeTxID
Propose a transaction to the Safe API client
- propose_safe_tx(safe_tx: SafeTxV1 | SafeTxV2, submitter: AccountAPI | Annotated[ChecksumAddress, _AddressValidator] | str | None = None, sigs_by_signer: dict[Annotated[ChecksumAddress, _AddressValidator], MessageSignature] | None = None, contractTransactionHash: SafeTxID | None = None) SafeTxID
Propose a safe_tx to the Safe API client
- sign_message(msg: Any, **signer_options) MessageSignature | None
Sign a message.
- Parameters:
msg (Any) – The message to sign. Account plugins can handle various types of messages. For example,
KeyfileAccount
can handleSignableMessage
, str, int, and bytes. See these docs # noqa: E501 for more type information on theSignableMessage
type.**signer_options – Additional kwargs given to the signer to modify the signing operation.
- Returns:
The signature corresponding to the message.
- Return type:
MessageSignature
(optional)
- sign_transaction(txn: TransactionAPI, submit: bool = True, submitter: AccountAPI | Annotated[ChecksumAddress, _AddressValidator] | str | None = None, skip: list[AccountAPI | Annotated[ChecksumAddress, _AddressValidator] | str] | None = None, signatures_required: int | None = None, **signer_options) TransactionAPI | None
Sign the created safe transaction for the safe client to post. NOTE
signatures_required
is required if the transaction is increasting the threshold.- Parameters:
txn (
TransactionAPI
) – The contract transaction.submit (bool) – The option to submit the transaction. Defaults to
True
.submitter (Union[
AccountAPI
,AddressType
, str, None]) – Determine who is submitting the transaction. Defaults toNone
.skip (Optional[list[Union[
AccountAPI, `AddressType
, str]]]) – Allow bypassing any specified signer. Defaults toNone
.signatures_required (Optional[int]) – The amount of signers required to confirm the transaction. Defaults to
None
.**signer_options – Other signer options.
- Returns:
Returns
None
if the transaction is successful.- Return type:
Optional[
TransactionAPI
]
- submit_safe_tx(safe_tx: SafeTxV1 | SafeTxV2 | SafeTxID, submitter: AccountAPI | Annotated[ChecksumAddress, _AddressValidator] | str | None = None, **txn_options) ReceiptAPI
Submit the safe transaction using the submitter after all signatures have been collected.
- Parameters:
safe_tx (
SafeTX
) – The safe transaction to submit.submitter (Union[
AccountAPI
,AddressType
, str,None
]) – The submitter to use for the transaction. Defaults toNone
.
- Returns:
ReceiptAPI
- class ape_safe.accounts.SafeContainer(*, name: str, account_type: type[AccountAPI])
- property accounts: Iterator[AccountAPI]
All accounts.
- Returns:
Iterator[
AccountAPI
]
- property aliases: Iterator[str]
All available aliases.
- Returns:
Iterator[str]
- delete_account(alias: str)
Delete the local Safe account. NOTE: If the account does not exist, nothing happens.
- Parameters:
alias (str) – The alias the Safe account is saved under.
- load_account(alias: str) SafeAccount
Load the Safe account.
- Raises:
ApeSafeError – When the alias does not exist.
- Parameters:
alias (str) – The alias the Safe account is saved under.
- Returns:
The Safe account loaded.
- Return type:
- save_account(alias: str, address: str)
Save a new Safe to your ape configuration.
- Raises:
ApeSafeError – When the alias already exists.
- Parameters:
alias (str) – The alias to save the Safe under.
address (str) – The address of the Safe account.