Documentation
¶
Index ¶
- func NewCallDecoder(method *goethABI.Method) func(data []byte, res any) error
- func NewCallEncoder(method *goethABI.Method, args ...any) func() ([]byte, error)
- func NewContractErrorDecoder(contract *goethABI.Contract) func(err error) error
- type Call
- type CallOpts
- type Callable
- type Caller
- type Decoder
- type SelfCaller
- type SelfTransactableCaller
- type TransactableCall
- type Transactor
- type TypedCall
- type TypedCaller
- type TypedDecoder
- type TypedSelfCaller
- type TypedSelfTransactableCaller
- type TypedTransactableCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCallDecoder ¶
NewCallDecoder creates a new decoder for the given method and result.
It can be used to create a CallOpts.Decoder.
func NewCallEncoder ¶
NewCallEncoder creates a new encoder for the given method and arguments.
It can be used to create a CallOpts.Encoder.
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call is a contract call.
Using this type instead of performing the call directly allows to choose if the call should be executed immediately or passed as an argument to another function.
As a special case, if the address is zero, the call will not be executed but the decoder will still be called with nil as the data. This is useful mostly for testing purposes.
func (*Call) Address ¶
Address implements the Callable, Caller, TypedCaller, and Transactor interface.
type CallOpts ¶
type CallOpts struct {
// Client is the RPC client to use when performing the call or sending
// the transaction.
Client rpc.RPC
// Address is the address of the contract to call or send a transaction to.
Address types.Address
// Encoder is an optional encoder that will be used to encode the
// arguments of the contract call.
Encoder func() ([]byte, error)
// Decoder is an optional decoder that will be used to decode the result
// returned by the contract call.
Decoder func([]byte, any) error
// ErrorDecoder is an optional decoder that will be used to decode the
// error returned by the contract call.
ErrorDecoder func(err error) error
}
CallOpts are the options for New*Call functions.
type Callable ¶
type Callable interface {
// Address returns the address of the contract to call.
Address() types.Address
// CallData returns the encoded call data.
CallData() ([]byte, error)
}
Callable provides the data required to call a contract.
type Caller ¶
type Caller interface {
// Address returns the address of the contract to call.
Address() types.Address
// Client returns the RPC client to use when performing the call.
Client() rpc.RPC
// Call executes the call and decodes the result into res.
Call(ctx context.Context, number types.BlockNumber, res any) error
}
Caller can perform a call to a contract and decode the result.
type SelfCaller ¶
SelfCaller is a Callable that can perform a call by itself.
type SelfTransactableCaller ¶
type SelfTransactableCaller interface {
Callable
Caller
Transactor
Decoder
}
SelfTransactableCaller is a Callable that can perform a call or send a transaction by itself.
type TransactableCall ¶
type TransactableCall struct {
// contains filtered or unexported fields
}
TransactableCall works like Call but can be also used to send a transaction.
func NewTransactableCall ¶
func NewTransactableCall(opts CallOpts) *TransactableCall
NewTransactableCall creates a new TransactableCall instance.
func (*TransactableCall) SendTransaction ¶
func (t *TransactableCall) SendTransaction(ctx context.Context) (*types.Hash, *types.Transaction, error)
SendTransaction sends a call as a transaction.
func (*TransactableCall) Simulate ¶
func (t *TransactableCall) Simulate(ctx context.Context, number types.BlockNumber) error
Simulate implements the Transactor interface.
type Transactor ¶
type Transactor interface {
// Address returns the address of the contract to send a transaction to.
Address() types.Address
// Client returns the RPC client to use when sending the transaction.
Client() rpc.RPC
// Simulate simulates the transaction. If the transaction fails, the
// error will be returned.
Simulate(ctx context.Context, number types.BlockNumber) error
// SendTransaction sends a call as a transaction.
SendTransaction(ctx context.Context) (*types.Hash, *types.Transaction, error)
}
Transactor can send a transaction to a contract.
type TypedCall ¶
type TypedCall[T any] struct { // contains filtered or unexported fields }
TypedCall is a Call with a typed result.
func NewTypedCall ¶
NewTypedCall creates a new TypedCall instance.
type TypedCaller ¶
type TypedCaller[T any] interface { // Address returns the address of the contract to call. Address() types.Address // Client returns the RPC client to use when performing the call. Client() rpc.RPC // Call executes the call and decodes the result into res. Call(ctx context.Context, number types.BlockNumber) (T, error) }
TypedCaller can perform a call to a contract and decode the result.
type TypedDecoder ¶
TypedDecoder decodes the data returned by the contract call.
type TypedSelfCaller ¶
type TypedSelfCaller[T any] interface { Callable TypedCaller[T] TypedDecoder[T] Decoder }
TypedSelfCaller is a Callable that can perform a call by itself.
type TypedSelfTransactableCaller ¶
type TypedSelfTransactableCaller[T any] interface { Callable TypedCaller[T] Transactor Decoder }
TypedSelfTransactableCaller is a Callable that can perform a call or send a transaction by itself.
type TypedTransactableCall ¶
type TypedTransactableCall[T any] struct { // contains filtered or unexported fields }
TypedTransactableCall is a TransactableCall with a typed result.
func NewTypedTransactableCall ¶
func NewTypedTransactableCall[T any](opts CallOpts) *TypedTransactableCall[T]
NewTypedTransactableCall creates a new TypedTransactableCall instance.
func (*TypedTransactableCall[T]) Call ¶
func (t *TypedTransactableCall[T]) Call(ctx context.Context, number types.BlockNumber) (T, error)
Call executes the call and returns the decoded result.
func (*TypedTransactableCall[T]) Decode ¶
func (t *TypedTransactableCall[T]) Decode(data []byte) (T, error)
Decode decodes the result of the call.