pub struct SafeTransaction {
pub to: [u8; 20],
pub value: [u8; 32],
pub data: Vec<u8>,
pub operation: Operation,
pub safe_tx_gas: [u8; 32],
pub base_gas: [u8; 32],
pub gas_price: [u8; 32],
pub gas_token: [u8; 20],
pub refund_receiver: [u8; 20],
pub nonce: [u8; 32],
}Expand description
A Gnosis Safe transaction for EIP-712 typed signing.
All u256 fields are stored as 32-byte big-endian arrays to avoid
overflow issues and match the ABI encoding directly.
Fields§
§to: [u8; 20]Target address of the transaction.
value: [u8; 32]ETH value in wei (32-byte BE uint256).
data: Vec<u8>Transaction calldata.
operation: OperationCall type: Call or DelegateCall.
safe_tx_gas: [u8; 32]Gas allocated for the Safe execution (after gasleft() check).
base_gas: [u8; 32]Gas costs not related to the Safe execution (signatures, base overhead).
gas_price: [u8; 32]Gas price used for the refund calculation. 0 = no refund.
gas_token: [u8; 20]Token address for gas payment (0x0 = ETH).
refund_receiver: [u8; 20]Address that receives the gas refund (0x0 = tx.origin).
nonce: [u8; 32]Safe nonce for replay protection.
Implementations§
Source§impl SafeTransaction
impl SafeTransaction
Sourcepub fn type_hash() -> [u8; 32]
pub fn type_hash() -> [u8; 32]
The Safe’s SAFE_TX_TYPEHASH.
keccak256("SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)")
Sourcepub fn struct_hash(&self) -> [u8; 32]
pub fn struct_hash(&self) -> [u8; 32]
Compute the EIP-712 struct hash for this transaction.
keccak256(abi.encode(SAFE_TX_TYPEHASH, to, value, keccak256(data), operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, nonce))
Sourcepub fn signing_hash(&self, domain_separator: &[u8; 32]) -> [u8; 32]
pub fn signing_hash(&self, domain_separator: &[u8; 32]) -> [u8; 32]
Compute the EIP-712 signing hash (safeTxHash).
keccak256("\x19\x01" || domainSeparator || structHash)
Sourcepub fn sign(
&self,
signer: &EthereumSigner,
domain_separator: &[u8; 32],
) -> Result<EthereumSignature, SignerError>
pub fn sign( &self, signer: &EthereumSigner, domain_separator: &[u8; 32], ) -> Result<EthereumSignature, SignerError>
Sign this Safe transaction using EIP-712.
Returns an EthereumSignature that can be packed with encode_signatures.
Sourcepub fn encode_exec_transaction(
&self,
signatures: &[EthereumSignature],
) -> Result<Vec<u8>, SignerError>
pub fn encode_exec_transaction( &self, signatures: &[EthereumSignature], ) -> Result<Vec<u8>, SignerError>
ABI-encode the execTransaction(...) calldata.
This produces the full calldata to call execTransaction on the Safe contract,
ready for use in a transaction’s data field.
Trait Implementations§
Source§impl Clone for SafeTransaction
impl Clone for SafeTransaction
Source§fn clone(&self) -> SafeTransaction
fn clone(&self) -> SafeTransaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more