Documentation
¶
Index ¶
- Constants
- Variables
- func CalcSafeAddress(...) (common.Address, error)
- func ExampleExecTransaction()
- func ExampleExecTransactionWithSignature()
- func ExampleGetNonce()
- func ExampleMultipleSigners()
- func ExampleSignSafeTransaction()
- func ExampleUseNonce()
- func ExecTransactionData(to common.Address, value *big.Int, txData []byte, operation uint8, ...) ([]byte, error)
- func FormatSignatureBytes(signatures ...[]byte) []byte
- func GetNonce(ctx context.Context, client *ethclient.Client, safeAddress common.Address, ...) (*big.Int, error)
- func GetNonceData() ([]byte, error)
- func GetSafeTransactionHash(safeAddress common.Address, chainId *big.Int, txData SafeTransactionData) (common.Hash, error)
- func GetSignerAddress(txHash common.Hash, signature []byte) (common.Address, error)
- func ParseExecTransactionResult(result []byte) (bool, error)
- func ParseNonceResult(result []byte) (*big.Int, error)
- func SignSafeTransaction(safeAddress common.Address, chainId *big.Int, txData SafeTransactionData, ...) ([]byte, error)
- func SignSafeTransactionHash(txHash common.Hash, privateKey *ecdsa.PrivateKey) ([]byte, error)
- type SafeTransactionData
Constants ¶
const (
EIP712_SAFE_TX_TYPE = "" /* 164-byte string literal not displayed */
)
EIP712 domain and type constants for Safe transactions
Variables ¶
var ABI_SafeWallet = `` /* 1684-byte string literal not displayed */
Functions ¶
func CalcSafeAddress ¶
func ExampleExecTransaction ¶
func ExampleExecTransaction()
ExampleExecTransaction demonstrates how to use ExecTransactionData and ParseExecTransactionResult functions
func ExampleExecTransactionWithSignature ¶
func ExampleExecTransactionWithSignature()
ExampleExecTransactionWithSignature demonstrates how to use the signature with execTransaction
func ExampleGetNonce ¶
func ExampleGetNonce()
ExampleGetNonce demonstrates how to use GetNonceData and ParseNonceResult functions
func ExampleMultipleSigners ¶
func ExampleMultipleSigners()
ExampleMultipleSigners demonstrates how to collect signatures from multiple owners
func ExampleSignSafeTransaction ¶
func ExampleSignSafeTransaction()
ExampleSignSafeTransaction demonstrates how to sign a Safe transaction using a private key
func ExampleUseNonce ¶
func ExampleUseNonce()
ExampleUseNonce shows how to use the nonce value in a transaction
func ExecTransactionData ¶
func ExecTransactionData( to common.Address, value *big.Int, txData []byte, operation uint8, safeTxGas *big.Int, baseGas *big.Int, gasPrice *big.Int, gasToken common.Address, refundReceiver common.Address, signatures []byte, ) ([]byte, error)
ExecTransactionData generates contract call data for execTransaction function This function is used to execute a transaction through a Safe wallet to: destination address of the transaction value: ether value of the transaction txData: data payload of the transaction operation: operation type (0 = call, 1 = delegatecall) safeTxGas: gas that should be used for the safe transaction baseGas: gas costs for data used to trigger the safe transaction gasPrice: gas price that should be used for the payment calculation gasToken: token address (or 0 if ETH) that is used for the payment refundReceiver: address of receiver of gas payment (or 0 if tx.origin) signatures: packed signature data ({bytes32 r}{bytes32 s}{uint8 v})
func FormatSignatureBytes ¶
FormatSignatureBytes formats multiple signatures into the format expected by the Safe contract Each signature should be 65 bytes (r, s, v) The signatures should be sorted by signer address (ascending order)
func GetNonceData ¶
GetNonceData generates contract call data for nonce function This function is used to query the current nonce of a Safe wallet
func GetSafeTransactionHash ¶
func GetSafeTransactionHash(safeAddress common.Address, chainId *big.Int, txData SafeTransactionData) (common.Hash, error)
GetSafeTransactionHash calculates the EIP712 hash of a Safe transaction safeAddress: the address of the Safe contract chainId: the chain ID of the network txData: the Safe transaction data
func GetSignerAddress ¶
GetSignerAddress recovers the signer address from a signature and transaction hash txHash: the EIP712 hash of the Safe transaction signature: the 65-byte signature (r, s, v) Returns the address of the signer
func ParseExecTransactionResult ¶
ParseExecTransactionResult parses the result of an execTransaction call and returns the success status result: the raw result bytes from the contract call
func ParseNonceResult ¶
ParseNonceResult parses the result of a nonce call and returns the nonce as a big.Int result: the raw result bytes from the contract call
func SignSafeTransaction ¶
func SignSafeTransaction(safeAddress common.Address, chainId *big.Int, txData SafeTransactionData, privateKey *ecdsa.PrivateKey) ([]byte, error)
SignSafeTransaction signs a Safe transaction using a private key safeAddress: the address of the Safe contract chainId: the chain ID of the network txData: the Safe transaction data privateKey: the private key to sign with Returns the signature in the format required by the Safe contract (65 bytes: r, s, v)
func SignSafeTransactionHash ¶
SignSafeTransactionHash signs a Safe transaction hash using a private key txHash: the EIP712 hash of the Safe transaction privateKey: the private key to sign with Returns the signature in the format required by the Safe contract (65 bytes: r, s, v)
Types ¶
type SafeTransactionData ¶
type SafeTransactionData struct {
To common.Address
Value *big.Int
Data []byte
Operation uint8
SafeTxGas *big.Int
BaseGas *big.Int
GasPrice *big.Int
GasToken common.Address
RefundReceiver common.Address
Nonce *big.Int
}
SafeTransactionData represents the data of a Safe transaction