Documentation
¶
Overview ¶
Package base provides core utilities for interacting with the blockchain, including transaction setup, contract calls, and error handling.
Index ¶
- func FailedTx(err error) (string, error)
- func GenCallError(kind string, buildError func(any) error, ...) func(field string, err error) error
- func SuccessTx(hash string) (string, error)
- type CallError
- type IBaseInteractions
- type Interactions
- func (i *Interactions) BaseCallSetup() *bind.CallOpts
- func (i *Interactions) BaseTxSetup() (*bind.TransactOpts, error)
- func (i *Interactions) CatchTx(tx *ethTypes.Transaction, err error) (string, error)
- func (i *Interactions) CheckSignatures(contractAddress common.Address, signatures []hex.Signature) error
- func (i *Interactions) Disperse(addresses []common.Address, totalValue uint) (string, error)
- func (i *Interactions) Safe() bool
- func (i *Interactions) SendAllFunds(to common.Address) (*ethTypes.Transaction, error)
- func (i *Interactions) SetDisperse(_ string) error
- func (i *Interactions) TransferETH(to common.Address, value *big.Int) (*ethTypes.Transaction, error)
- func (i *Interactions) VerifyTransaction(ctx context.Context, to common.Address, data []byte, value int64) error
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FailedTx ¶
FailedTx returns an empty string and the given error. It is intended to be used to signal that a transaction has failed.
Types ¶
type CallError ¶
type CallError struct {
Kind string // The kind of call, e.g., "call", "deploy", etc.
Method string
Err error
}
CallError represents an error that occurred during a contract call
func WrapCallError ¶
WrapCallError wraps an error with contract call context information
type IBaseInteractions ¶
type IBaseInteractions interface {
VerifyTransaction(ctx context.Context, to common.Address, data []byte, value int64) error
}
IBaseInteractions defines the interface for verifying transactions.
type Interactions ¶
type Interactions struct {
Ctx context.Context
Client simulated.Client
Address common.Address
TxOptsFn transaction.TxOptsBuilderFunc
// contains filtered or unexported fields
}
Interactions holds the context, client, sender address, private key, disperse contract, and explorer URL.
func NewBaseInteractions ¶
func NewBaseInteractions( client simulated.Client, pk *ecdsa.PrivateKey, explorer *string, safe bool, txOptsFn ...transaction.TxOptsBuilderFunc, ) *Interactions
NewBaseInteractions creates a new instance of BaseInteractions for blockchain interaction.
func (*Interactions) BaseCallSetup ¶
func (i *Interactions) BaseCallSetup() *bind.CallOpts
BaseCallSetup returns the call options for read-only contract operations.
func (*Interactions) BaseTxSetup ¶
func (i *Interactions) BaseTxSetup() (*bind.TransactOpts, error)
BaseTxSetup sets up transaction options (nonce, gas price, chain ID, etc.) for sending a transaction.
func (*Interactions) CatchTx ¶
func (i *Interactions) CatchTx(tx *ethTypes.Transaction, err error) (string, error)
CatchTx waits for a transaction to be mined and returns its hash or an error message.
func (*Interactions) CheckSignatures ¶
func (i *Interactions) CheckSignatures(contractAddress common.Address, signatures []hex.Signature) error
CheckSignatures checks if a contract supports specific function signatures.
func (*Interactions) Disperse ¶
Disperse uses the disperse contract to send funds to multiple addresses.
func (*Interactions) Safe ¶
func (i *Interactions) Safe() bool
Safe returns whether the interactions are in safe mode
func (*Interactions) SendAllFunds ¶
func (i *Interactions) SendAllFunds(to common.Address) (*ethTypes.Transaction, error)
SendAllFunds transfers the entire balance to a designated address after fee estimation.
func (*Interactions) SetDisperse ¶
func (i *Interactions) SetDisperse(_ string) error
SetDisperse initializes the disperse contract for multi-address fund transfers.
func (*Interactions) TransferETH ¶
func (i *Interactions) TransferETH(to common.Address, value *big.Int) (*ethTypes.Transaction, error)
TransferETH transfers Ether to the specified address, ensuring sufficient balance and proper fee estimation.
func (*Interactions) VerifyTransaction ¶
func (i *Interactions) VerifyTransaction(ctx context.Context, to common.Address, data []byte, value int64) error
VerifyTransaction simulates a contract call to verify transaction validity.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session holds call options and bound contract instance for contract interactions
func (*Session) Instance ¶
func (s *Session) Instance() *bind.BoundContract
Instance returns the bound contract instance