Documentation
¶
Overview ¶
Example (Rpc_getBlockByNumber) ¶
client := rpc.NewClient(getRPCURL())
blockRef := rpc.LatestBlock
if os.Getenv("ETH_GO_RPC_BLOCK_NUMBER") != "" {
var err error
blockNumber, err := strconv.ParseUint(os.Getenv("ETH_GO_RPC_BLOCK_NUMBER"), 0, 64)
if err != nil {
panic(fmt.Errorf("parse custom block number info: %w", err))
}
blockRef = rpc.BlockNumber(blockNumber)
}
result, err := client.GetBlockByNumber(context.Background(), blockRef, rpc.WithGetBlockFullTransaction())
if err != nil {
panic(fmt.Errorf("get block by number %s: %w", blockRef, err))
}
bytes, err := rpc.MarshalJSONRPC(result)
if err != nil {
panic(fmt.Errorf("json marshal response: %w", err))
}
fmt.Println(string(bytes))
Index ¶
- Variables
- func B(input string) []byte
- func CanonicalHex(input string) string
- func ConcatHex(with0x bool, in ...string) (out string)
- func DecimalsInBigInt(decimal uint32) *big.Int
- func DeclarationTypeNames() []string
- func Has0xPrefix(input string) bool
- func Keccak256(data ...[]byte) []byte
- func MustDecodeString(hexStr string) []byte
- func PrefixedHex(input string) string
- func PrettifyBigIntWithDecimals(in *big.Int, precision, truncateDecimalCount uint) string
- func SanitizeHex(input string) string
- func StateMutabilityNames() []string
- func TransactionTypeNames() []string
- func TypeKindNames() []string
- type ABI
- func (a *ABI) FindFunction(functionHash []byte) *MethodDefdeprecated
- func (a *ABI) FindFunctionByHash(functionHash []byte) *MethodDef
- func (a *ABI) FindFunctionByName(name string) *MethodDef
- func (a *ABI) FindFunctionsByName(name string) []*MethodDef
- func (a *ABI) FindLog(topic []byte) *LogEventDef
- func (a *ABI) FindLogByName(name string) *LogEventDef
- func (a *ABI) FindLogByTopic(topic []byte) *LogEventDef
- func (a *ABI) FindLogsByName(name string) []*LogEventDef
- func (a *ABI) FindLogsByTopic(topic []byte) []*LogEventDef
- type Address
- func (a Address) Bytes() []byte
- func (a Address) ID() uint64
- func (a Address) MarshalJSON() ([]byte, error)
- func (a Address) MarshalJSONRPC() ([]byte, error)
- func (a Address) MarshalText() ([]byte, error)
- func (a Address) Pretty() string
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(data []byte) error
- func (a *Address) UnmarshalText(data []byte) error
- type AddressArray
- type AddressType
- type ArrayType
- type BigIntArray
- type BoolArray
- type BooleanType
- type Bytes
- func (h Bytes) Bytes() []byte
- func (h Bytes) ID() uint64
- func (h Bytes) MarshalJSON() ([]byte, error)
- func (h Bytes) MarshalJSONRPC() ([]byte, error)
- func (h Bytes) MarshalText() ([]byte, error)
- func (h Bytes) Pretty() string
- func (h Bytes) String() string
- func (h *Bytes) UnmarshalJSON(data []byte) error
- func (h *Bytes) UnmarshalText(data []byte) error
- type BytesType
- type DeclarationType
- type Decoder
- func (d *Decoder) Read(typeName string) (interface{}, error)
- func (d *Decoder) ReadAddress() (out Address, err error)
- func (d *Decoder) ReadBigInt() (out *big.Int, err error)
- func (d *Decoder) ReadBool() (out bool, err error)
- func (d *Decoder) ReadBuffer(byteCount uint64) ([]byte, error)
- func (d *Decoder) ReadBytes() ([]byte, error)
- func (d *Decoder) ReadFixedBytes(byteCount uint64) ([]byte, error)
- func (d *Decoder) ReadMethod() (out string, err error)
- func (d *Decoder) ReadMethodCall() (*MethodCall, error)
- func (d *Decoder) ReadOutput(parameters []*MethodParameter) (out []interface{}, err error)
- func (d *Decoder) ReadString() (out string, err error)
- func (d *Decoder) ReadUint64() (out uint64, err error)
- func (d *Decoder) SetBytes(input []byte) *Decoder
- func (d *Decoder) String() string
- type Encoder
- func (e *Encoder) Buffer() []byte
- func (e *Encoder) String() string
- func (e *Encoder) Write(parameter *MethodParameter, in interface{}) error
- func (e *Encoder) WriteLogData(parameters []*LogParameter, data []interface{}) error
- func (e *Encoder) WriteLogParameter(parameter *LogParameter, in interface{}) error
- func (e *Encoder) WriteMethodCall(method *MethodCall) error
- func (e *Encoder) WriteParameters(parameters []*MethodParameter, data []interface{}) error
- type ErrDecoding
- type FixedSizeArrayType
- type FixedSizeBytesType
- type FixedUint64
- type Hash
- func (h Hash) Bytes() []byte
- func (h Hash) ID() uint64
- func (h Hash) MarshalJSON() ([]byte, error)
- func (h Hash) MarshalJSONRPC() ([]byte, error)
- func (h Hash) MarshalText() ([]byte, error)
- func (h Hash) Pretty() string
- func (h Hash) String() string
- func (h *Hash) UnmarshalJSON(data []byte) error
- func (h *Hash) UnmarshalText(data []byte) error
- type Hex
- func (h Hex) Bytes() []byte
- func (h Hex) ID() uint64
- func (h Hex) MarshalJSON() ([]byte, error)
- func (h Hex) MarshalJSONRPC() ([]byte, error)
- func (h Hex) MarshalText() ([]byte, error)
- func (h Hex) Pretty() string
- func (h Hex) String() string
- func (h *Hex) UnmarshalJSON(data []byte) error
- func (h *Hex) UnmarshalText(data []byte) error
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type InvertedSignature
- func (s InvertedSignature) R() *big.Int
- func (s InvertedSignature) Recover(messageHash Hash) (Address, error)
- func (s InvertedSignature) RecoverPersonal(signingData Hex) (Address, error)
- func (s InvertedSignature) S() *big.Int
- func (s InvertedSignature) String() string
- func (s InvertedSignature) ToSignature() (out Signature)
- func (s InvertedSignature) V() byte
- type KeyBag
- type Log
- type LogDecoder
- type LogEvent
- type LogEventDef
- type LogParameter
- type MethodCall
- type MethodDef
- func (f *MethodDef) DecodeOutput(data []byte) ([]interface{}, error)
- func (f *MethodDef) DecodeOutputFromString(data string) ([]interface{}, error)
- func (f *MethodDef) DecodeToObjectFromBytes(data []byte) (out map[string]interface{}, err error)
- func (f *MethodDef) DecodeToObjectFromDecoder(decoder *Decoder) (out map[string]interface{}, err error)
- func (f *MethodDef) DecodeToObjectFromString(data string) (out map[string]interface{}, err error)
- func (f *MethodDef) MethodID() []byte
- func (f *MethodDef) NewCall(args ...interface{}) *MethodCall
- func (f *MethodDef) NewCallFromString(args ...string) *MethodCall
- func (f *MethodDef) Signature() string
- func (f *MethodDef) String() string
- type MethodParameter
- type PrivateKey
- func (p *PrivateKey) Bytes() (out []byte)
- func (p *PrivateKey) MarshalJSON() ([]byte, error)
- func (p *PrivateKey) PublicKey() *PublicKey
- func (p *PrivateKey) Sign(messageHash Hash) (out Signature, err error)
- func (p *PrivateKey) SignPersonal(signingData Hex) (out Signature, err error)
- func (p *PrivateKey) String() string
- func (p *PrivateKey) UnmarshalJSON(v []byte) (err error)
- type PublicKey
- type Signature
- func (s Signature) R() *big.Int
- func (s Signature) Recover(messageHash Hash) (Address, error)
- func (s Signature) RecoverPersonal(signingData Hex) (Address, error)
- func (s Signature) S() *big.Int
- func (s Signature) String() string
- func (s Signature) ToInverted() (out InvertedSignature)
- func (s Signature) V() byte
- type SignedFixedPointType
- type SignedIntegerType
- type SolidityType
- type StateMutability
- type StringArray
- type StringType
- type StructComponent
- type StructType
- type Timestamp
- type Token
- type TokenAmount
- type Topic
- type TransactionType
- type TypeKind
- type Uint16
- type Uint16Array
- type Uint256
- type Uint32
- type Uint32Array
- type Uint64
- type Uint64Array
- type Uint8
- type Uint8Array
- type UnsignedFixedPointType
- type UnsignedIntegerType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ETHToken = &Token{ Name: "Ethereum", Symbol: "ETH", Address: nil, Decimals: 18, }
var KnownSignatures = map[string]string{}/* 149637 elements not displayed */
Functions ¶
func CanonicalHex ¶
CanonicalHex receives an input and return it's canonical form, i.e. the single unique well-formed which in our case is an all-lower case version with even number of characters.
The only differences with `SanitizeHexInput` here is an additional call to `strings.ToLower` before returning the result.
func DecimalsInBigInt ¶
func DeclarationTypeNames ¶
func DeclarationTypeNames() []string
DeclarationTypeNames returns a list of possible string values of DeclarationType.
func Has0xPrefix ¶
func MustDecodeString ¶
func PrefixedHex ¶
PrefixedHex is CanonicalHex but with 0x prefix
func SanitizeHex ¶
SanitizeHex removes the prefix `0x` if it exists and ensures there is an even number of characters in the string, padding on the left of the string is it's not the case.
func StateMutabilityNames ¶
func StateMutabilityNames() []string
StateMutabilityNames returns a list of possible string values of StateMutability.
func TransactionTypeNames ¶
func TransactionTypeNames() []string
TransactionTypeNames returns a list of possible string values of TransactionType.
func TypeKindNames ¶
func TypeKindNames() []string
TypeKindNames returns a list of possible string values of TypeKind.
Types ¶
type ABI ¶
type ABI struct {
LogEventsMap map[string][]*LogEventDef
FunctionsMap map[string][]*MethodDef
ConstructorsMap map[string][]*MethodDef
LogEventsByNameMap map[string][]*LogEventDef
FunctionsByNameMap map[string][]*MethodDef
ConstructorsByNameMap map[string][]*MethodDef
}
ABI is our custom internal definition of a contract's ABI that bridges the information between the two ABI like formats for contract's, i.e. `.abi` file and AST file as output by `solc` compiler.
FIXME: Our internal structure is wrong because multiple functions and multiple events can exist under the same name. This is problematic right now because we use a one level mapping and only the "last seen" event wins. This will require a refactor and will trickle down in a few places.
func ParseABIFromBytes ¶
func (*ABI) FindFunction
deprecated
func (*ABI) FindFunctionByHash ¶
FindFunctionByHash finds the function with the give `hash`.
func (*ABI) FindFunctionByName ¶
FindFunctionByName finds the first function with the give `name`. Multiple functions could have the same name, use `FindFunctionsByName` to get them all.
func (*ABI) FindFunctionsByName ¶
FindFunctionsByName returns **all** functions with the give `name`.
func (*ABI) FindLog ¶
func (a *ABI) FindLog(topic []byte) *LogEventDef
Deprecated Use FindLogByTopic
func (*ABI) FindLogByName ¶
func (a *ABI) FindLogByName(name string) *LogEventDef
FindLogByName finds the first log with the give `topic`. Multiple events could have the same topic, use `FindLogsByName` to get them all.
func (*ABI) FindLogByTopic ¶
func (a *ABI) FindLogByTopic(topic []byte) *LogEventDef
FindLogByTopic finds the first log with the give `topic`. Multiple events could have the same topic, use `FindLogByTopic` to get them all.
func (*ABI) FindLogsByName ¶
func (a *ABI) FindLogsByName(name string) []*LogEventDef
FindLogsByName returns **all** logs with the give `topic`.
func (*ABI) FindLogsByTopic ¶
func (a *ABI) FindLogsByTopic(topic []byte) []*LogEventDef
FindLogByTopic returns **all** logs with the give `topic`.
type Address ¶
type Address []byte
func MustNewAddress ¶
MustNewAddress is exactly like NewAddress but it panics if an error occurrs.
See [NewAdress] for detaiks.
func MustNewAddressLoose ¶
MustNewAddressLoose is exactly like NewAddressLoose but it panics if an error occurrs.
See NewAddressLoose for detaiks.
func NewAddress ¶
NewAddress creates an address where the input **must** contain exactly 20 bytes.
If the actual input is not an hexadecimal string, an error is returned or the decoded lenght is not exactly 20 bytes, an error is returned.
func NewAddressLoose ¶
NewAddressLoose creates an address where the input can contain more than 20 bytes (truncated) or less than 20 bytes (left as-is).
If the actual input is not an hexadecimal string, an error is returned.
func (Address) MarshalJSON ¶
func (Address) MarshalJSONRPC ¶
func (Address) MarshalText ¶
func (*Address) UnmarshalJSON ¶
func (*Address) UnmarshalText ¶
type AddressArray ¶
type AddressArray []Address
func (AddressArray) At ¶
func (a AddressArray) At(index uint64, value interface{})
type AddressType ¶
type AddressType struct {
}
func (AddressType) IsDynamic ¶
func (t AddressType) IsDynamic() bool
func (AddressType) Kind ¶
func (a AddressType) Kind() TypeKind
func (AddressType) Name ¶
func (t AddressType) Name() string
type ArrayType ¶
type ArrayType struct {
// ElementType represents the underlying stored element
ElementType SolidityType
}
type BigIntArray ¶
func (BigIntArray) At ¶
func (a BigIntArray) At(index uint64, value interface{})
type BooleanType ¶
type BooleanType struct {
}
func (BooleanType) IsDynamic ¶
func (t BooleanType) IsDynamic() bool
func (BooleanType) Kind ¶
func (a BooleanType) Kind() TypeKind
func (BooleanType) Name ¶
func (t BooleanType) Name() string
type Bytes ¶
type Bytes []byte
func MustNewBytes ¶
func (Bytes) MarshalJSON ¶
func (Bytes) MarshalJSONRPC ¶
func (Bytes) MarshalText ¶
func (*Bytes) UnmarshalJSON ¶
func (*Bytes) UnmarshalText ¶
type DeclarationType ¶
type DeclarationType int
ENUM(
Function Constructor Receive Fallback Event Error
)
const ( // DeclarationTypeFunction is a DeclarationType of type Function. DeclarationTypeFunction DeclarationType = iota // DeclarationTypeConstructor is a DeclarationType of type Constructor. DeclarationTypeConstructor // DeclarationTypeReceive is a DeclarationType of type Receive. DeclarationTypeReceive // DeclarationTypeFallback is a DeclarationType of type Fallback. DeclarationTypeFallback // DeclarationTypeEvent is a DeclarationType of type Event. DeclarationTypeEvent // DeclarationTypeError is a DeclarationType of type Error. DeclarationTypeError )
func ParseDeclarationType ¶
func ParseDeclarationType(name string) (DeclarationType, error)
ParseDeclarationType attempts to convert a string to a DeclarationType
func (DeclarationType) MarshalText ¶
func (x DeclarationType) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method
func (DeclarationType) String ¶
func (x DeclarationType) String() string
String implements the Stringer interface.
func (*DeclarationType) UnmarshalText ¶
func (x *DeclarationType) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoderFromString ¶
func (*Decoder) ReadAddress ¶
func (*Decoder) ReadMethod ¶
func (*Decoder) ReadMethodCall ¶
func (d *Decoder) ReadMethodCall() (*MethodCall, error)
func (*Decoder) ReadOutput ¶
func (d *Decoder) ReadOutput(parameters []*MethodParameter) (out []interface{}, err error)
func (*Decoder) ReadString ¶
func (*Decoder) ReadUint64 ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder() *Encoder
func (*Encoder) Write ¶
func (e *Encoder) Write(parameter *MethodParameter, in interface{}) error
func (*Encoder) WriteLogData ¶
func (e *Encoder) WriteLogData(parameters []*LogParameter, data []interface{}) error
func (*Encoder) WriteLogParameter ¶
func (e *Encoder) WriteLogParameter(parameter *LogParameter, in interface{}) error
func (*Encoder) WriteMethodCall ¶
func (e *Encoder) WriteMethodCall(method *MethodCall) error
func (*Encoder) WriteParameters ¶
func (e *Encoder) WriteParameters(parameters []*MethodParameter, data []interface{}) error
type ErrDecoding ¶
type ErrDecoding struct {
// contains filtered or unexported fields
}
func NewErrDecoding ¶
func NewErrDecoding(message string, args ...interface{}) *ErrDecoding
func (*ErrDecoding) Error ¶
func (e *ErrDecoding) Error() string
type FixedSizeArrayType ¶
type FixedSizeArrayType struct {
// ElementType represents the underlying stored element
ElementType SolidityType
// Length is the number of fixed element this array contains
Length uint
}
func (FixedSizeArrayType) IsDynamic ¶
func (t FixedSizeArrayType) IsDynamic() bool
func (FixedSizeArrayType) Kind ¶
func (t FixedSizeArrayType) Kind() TypeKind
func (FixedSizeArrayType) Name ¶
func (t FixedSizeArrayType) Name() string
type FixedSizeBytesType ¶
type FixedSizeBytesType struct {
// ByteSize is the number of bytes taken by this type, range of values is between 1 and 32 (inclusive)
ByteSize uint
}
func (FixedSizeBytesType) IsDynamic ¶
func (t FixedSizeBytesType) IsDynamic() bool
func (FixedSizeBytesType) Kind ¶
func (t FixedSizeBytesType) Kind() TypeKind
func (FixedSizeBytesType) Name ¶
func (t FixedSizeBytesType) Name() string
type FixedUint64 ¶
type FixedUint64 uint64
FixedUint64 is a fixed size uint64, marshalled as a fixed 8 bytes big endian
func (*FixedUint64) MarshalJSONRPC ¶
func (n *FixedUint64) MarshalJSONRPC() ([]byte, error)
func (*FixedUint64) UnmarshalText ¶
func (b *FixedUint64) UnmarshalText(text []byte) error
type Hash ¶
type Hash []byte
func MustNewHash ¶
func (Hash) MarshalJSON ¶
func (Hash) MarshalJSONRPC ¶
func (Hash) MarshalText ¶
func (*Hash) UnmarshalJSON ¶
func (*Hash) UnmarshalText ¶
type Hex ¶
type Hex []byte
func MustNewHex ¶
func (Hex) MarshalJSON ¶
func (Hex) MarshalJSONRPC ¶
func (Hex) MarshalText ¶
func (*Hex) UnmarshalJSON ¶
func (*Hex) UnmarshalText ¶
type InvertedSignature ¶
type InvertedSignature [65]byte
InvertedSignature represents a standard Signature but the order of component `V` is inverted, being the last byte of the bytes (where it's the first byte in the standard `btcec` Signature).
The InverteSignature is in packed form of 65 bytes and order of the components is R (32 bytes) + S (32 bytes) + V (1 byte).
The components can be retrieved with `R()`, `S()` and `V()`.
This form is used on certain Ethereum construct like when doing a personal signing where the `V` component must be the last component of the signature for correct recovery.
func NewInvertedSignatureFromBytes ¶
func NewInvertedSignatureFromBytes(in []byte) (out InvertedSignature, err error)
func (InvertedSignature) R ¶
func (s InvertedSignature) R() *big.Int
R returns the R component of signature.
func (InvertedSignature) Recover ¶
func (s InvertedSignature) Recover(messageHash Hash) (Address, error)
RecoverPersonal is a shortcut method for `signature.ToSignature().Recover(messageHash)`.
func (InvertedSignature) RecoverPersonal ¶
func (s InvertedSignature) RecoverPersonal(signingData Hex) (Address, error)
RecoverPersonal is a shortcut method for `signature.ToSignature().RecoverPersonal(signingData)`.
func (InvertedSignature) S ¶
func (s InvertedSignature) S() *big.Int
S returns the R component of signature.
func (InvertedSignature) String ¶
func (s InvertedSignature) String() string
func (InvertedSignature) ToSignature ¶
func (s InvertedSignature) ToSignature() (out Signature)
func (InvertedSignature) V ¶
func (s InvertedSignature) V() byte
V returns the recovery ID according to Bitcoin rules for the signature recovery. Ethereum augmented recovery ID to protect agaisnt replay attacks is **not** applied here.
See https://bitcoin.stackexchange.com/a/38909 for extra details
type KeyBag ¶
type KeyBag struct {
Keys []*PrivateKey `json:"keys"`
}
KeyBag holds private keys in memory, for signing transactions.
type LogDecoder ¶
type LogDecoder struct {
DataDecoder *Decoder
// contains filtered or unexported fields
}
func NewLogDecoder ¶
func NewLogDecoder(logEvent *Log) *LogDecoder
func (*LogDecoder) ReadData ¶
func (d *LogDecoder) ReadData(typeName string) (out interface{}, err error)
func (*LogDecoder) ReadTopic ¶
func (d *LogDecoder) ReadTopic() ([]byte, error)
func (*LogDecoder) ReadTypedTopic ¶
func (d *LogDecoder) ReadTypedTopic(typeName string) (out interface{}, err error)
type LogEvent ¶
type LogEvent struct {
Def *LogEventDef
Data []interface{}
// contains filtered or unexported fields
}
func (*LogEvent) AppendArgFromString ¶
func (*LogEvent) MustEncode ¶
type LogEventDef ¶
type LogEventDef struct {
Name string
Parameters []*LogParameter
}
func (*LogEventDef) LogID ¶
func (l *LogEventDef) LogID() []byte
func (*LogEventDef) NewEvent ¶
func (f *LogEventDef) NewEvent(args ...interface{}) *LogEvent
returned instantiate a new event from the log definition and uses the received arguments as elements used to resolve the parameters values (indexed and non-indexed).
A call is a particular instance of a Method where ultimately the parameters's value will be resolved. A method call in opposition to a method definition can be encoded according to Ethereum rules or decode data returned for this call against the definition.
func (*LogEventDef) NewEventFromString ¶
func (f *LogEventDef) NewEventFromString(args ...string) *LogEvent
NewCallFromString works exactly like `NewCall“ except that it actually assumes all arguments are string version of the actual Ethereum types defined by the method and append them to the Data slice by calling `AppendArgFromString` which converts the string representation to the correct type.
func (*LogEventDef) Signature ¶
func (l *LogEventDef) Signature() string
func (*LogEventDef) String ¶
func (l *LogEventDef) String() string
type LogParameter ¶
type LogParameter struct {
Name string
TypeName string
Type SolidityType
Indexed bool
// Components represents that struct fields of a particular tuple. Only
// filled up when `TypeName` is equal to `tuple` (or array of tuples).
//
// TODO: This is a blind copy from Method as I think the same concept applies
// to event, needs to validate using a test in `eth-go`.
Components []*StructComponent
}
func (*LogParameter) GetName ¶
func (p *LogParameter) GetName(index int) string
type MethodCall ¶
type MethodCall struct {
MethodDef *MethodDef
Data []interface{}
// contains filtered or unexported fields
}
func (*MethodCall) AppendArg ¶
func (f *MethodCall) AppendArg(v interface{})
func (*MethodCall) AppendArgFromString ¶
func (f *MethodCall) AppendArgFromString(v string)
func (*MethodCall) Encode ¶
func (f *MethodCall) Encode() ([]byte, error)
func (*MethodCall) MarshalJSONRPC ¶
func (f *MethodCall) MarshalJSONRPC() ([]byte, error)
func (*MethodCall) MustEncode ¶
func (f *MethodCall) MustEncode() []byte
type MethodDef ¶
type MethodDef struct {
Name string
Parameters []*MethodParameter
ReturnParameters []*MethodParameter
StateMutability StateMutability
}
func MustNewMethodDef ¶
func NewMethodDef ¶
func (*MethodDef) DecodeOutput ¶
func (*MethodDef) DecodeOutputFromString ¶
func (*MethodDef) DecodeToObjectFromBytes ¶
func (*MethodDef) DecodeToObjectFromDecoder ¶
func (*MethodDef) DecodeToObjectFromString ¶
func (*MethodDef) NewCall ¶
func (f *MethodDef) NewCall(args ...interface{}) *MethodCall
NewCall instantiate a new call from the method definition and uses the received arguments as elements used to resolve the parameters values.
A call is a particular instance of a Method where ultimately the parameters's value will be resolved. A method call in opposition to a method definition can be encoded according to Ethereum rules or decode data returned for this call against the definition.
func (*MethodDef) NewCallFromString ¶
func (f *MethodDef) NewCallFromString(args ...string) *MethodCall
NewCallFromString works exactly like `NewCall“ except that it actually assumes all arguments are string version of the actual Ethereum types defined by the method and append them to the Data slice by calling `AppendArgFromString` which converts the string representation to the correct type.
type MethodParameter ¶
type MethodParameter struct {
// Name represents the name of the parameter as defined by the
// developer in the Solidity code of the contract.
Name string
// TypeName represents the type of the parameter, this is standard
// types known to Solidity. Array have a suffix `[]` (can be nested)
// and struct type is always `tuple` with an filled up `Components`
// defining the struct.
TypeName string
// Type represents the parsed type of this parameter.
Type SolidityType
// TypeMutability is unclear, requires more investigation, I don't recall
// to which Solidity concept it refers to.
TypeMutability string
// Payable determines if the parameter is a payable value so an
// Ether value.
Payable bool
// InternalType is the internal type to the contract, usually equal
// to `TypeName` but can be different for example if a type `uint`
// was defined, in this case `TypeName` will be `uint256` and internal
// type will be `uint`. Tuple which have `TypeName` `tuple` but internal
// type is `struct <Contract>.<Struct>` is another exceptions.
InternalType string
// Components represents that struct fields of a particular tuple. Only
// filled up when `TypeName` is equal to `tuple` (or array of tuples).
Components []*StructComponent
}
func (*MethodParameter) Signature ¶
func (p *MethodParameter) Signature() string
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func NewPrivateKey ¶
func NewPrivateKey(rawPrivateKey string) (*PrivateKey, error)
func NewRandomPrivateKey ¶
func NewRandomPrivateKey() (*PrivateKey, error)
func (*PrivateKey) Bytes ¶
func (p *PrivateKey) Bytes() (out []byte)
func (*PrivateKey) MarshalJSON ¶
func (p *PrivateKey) MarshalJSON() ([]byte, error)
func (*PrivateKey) PublicKey ¶
func (p *PrivateKey) PublicKey() *PublicKey
func (*PrivateKey) Sign ¶
func (p *PrivateKey) Sign(messageHash Hash) (out Signature, err error)
Sign generates the signature for the according message hash based on this private key using ECDSA signature rules.
See Signature documentation for more info about return signature format.
func (*PrivateKey) SignPersonal ¶
func (p *PrivateKey) SignPersonal(signingData Hex) (out Signature, err error)
SignPersonal computes the correct message from `signingData` according to [ERC-712](https://eips.ethereum.org/EIPS/eip-712) which is briefly `keccak256(bytesOf("\x19Ethereum Signed Message:\n") + bytesOf(toString(len(signingData))) + signingData)`.
This computed generated hash is then pass directly to `privateKey.Sign(personalMessageHash)`.
See Sign for more details.
func (*PrivateKey) String ¶
func (p *PrivateKey) String() string
func (*PrivateKey) UnmarshalJSON ¶
func (p *PrivateKey) UnmarshalJSON(v []byte) (err error)
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func NewPublicKeyFromECDSA ¶
type Signature ¶
type Signature [65]byte
Signature represents a btcec Signature as computed from ecdsa.SignCompact(), this signature is in packed form of 65 bytes with ordered V (1 byte) + R (32 bytes) + S (32 bytes).
The components can be retrieved with `R()`, `S()` and `V()`.
func NewSignatureFromBytes ¶
func (Signature) RecoverPersonal ¶
func (Signature) ToInverted ¶
func (s Signature) ToInverted() (out InvertedSignature)
ToInverted returns the InvertedSignature version of this Signature, this is that the components are ordered as `R`, `S` then `V` in the inverted version.
This form is used on certain Ethereum construct like when doing a personal signing where the `V` component must be the last component of the signature for correct recovery.
func (Signature) V ¶
V returns the recovery ID according to Bitcoin rules for the signature recovery. Ethereum augmented recovery ID to protect agaisnt replay attacks is **not** applied here.
See https://bitcoin.stackexchange.com/a/38909 for extra details
type SignedFixedPointType ¶
type SignedFixedPointType struct {
// BitsSize is the number of bites taken by this type, BitsSize / 8 = ByteSize, range of values is between 8 and 256 (inclusive) by step of 8
BitsSize uint
// ByteSize is the number of bytes taken by this type, ByteSize * 8 = BitsSize, range of values is between 1 and 32 (inclusive)
ByteSize uint
// Decimals represents the precision in decimals of this fixed type and will be between 0 and 80 (inclusive)
Decimals uint
}
func (SignedFixedPointType) IsDynamic ¶
func (t SignedFixedPointType) IsDynamic() bool
func (SignedFixedPointType) Kind ¶
func (t SignedFixedPointType) Kind() TypeKind
func (SignedFixedPointType) Name ¶
func (t SignedFixedPointType) Name() string
type SignedIntegerType ¶
type SignedIntegerType struct {
// BitsSize is the number of bites taken by this type, BitsSize / 8 = ByteSize, range of values is between 8 and 256 (inclusive) by step of 8
BitsSize uint
// ByteSize is the number of bytes taken by this type, ByteSize * 8 = BitsSize, range of values is between 1 and 32 (inclusive)
ByteSize uint
}
func (SignedIntegerType) IsDynamic ¶
func (t SignedIntegerType) IsDynamic() bool
func (SignedIntegerType) Kind ¶
func (t SignedIntegerType) Kind() TypeKind
func (SignedIntegerType) Name ¶
func (t SignedIntegerType) Name() string
type SolidityType ¶
func ParseType ¶
func ParseType(raw string) (SolidityType, error)
type StateMutability ¶
type StateMutability int
ENUM(
Pure View NonPayable Payable
)
const ( // StateMutabilityPure is a StateMutability of type Pure. StateMutabilityPure StateMutability = iota // StateMutabilityView is a StateMutability of type View. StateMutabilityView // StateMutabilityNonPayable is a StateMutability of type NonPayable. StateMutabilityNonPayable // StateMutabilityPayable is a StateMutability of type Payable. StateMutabilityPayable )
func ParseStateMutability ¶
func ParseStateMutability(name string) (StateMutability, error)
ParseStateMutability attempts to convert a string to a StateMutability
func (StateMutability) MarshalText ¶
func (x StateMutability) MarshalText() ([]byte, error)
MarshalText implements the text marshaller method
func (StateMutability) String ¶
func (x StateMutability) String() string
String implements the Stringer interface.
func (*StateMutability) UnmarshalText ¶
func (x *StateMutability) UnmarshalText(text []byte) error
UnmarshalText implements the text unmarshaller method
type StringArray ¶
type StringArray []string
func (StringArray) At ¶
func (a StringArray) At(index uint64, value interface{})
type StringType ¶
type StringType struct {
}
func (StringType) IsDynamic ¶
func (t StringType) IsDynamic() bool
func (StringType) Kind ¶
func (t StringType) Kind() TypeKind
func (StringType) Name ¶
func (t StringType) Name() string
type StructComponent ¶
type StructComponent struct {
InternalType string
Name string
TypeName string
Type SolidityType
}
func (*StructComponent) String ¶
func (c *StructComponent) String() string
type StructType ¶
type StructType struct {
}
func (StructType) IsDynamic ¶
func (t StructType) IsDynamic() bool
func (StructType) Kind ¶
func (t StructType) Kind() TypeKind
func (StructType) Name ¶
func (t StructType) Name() string
type Timestamp ¶
Timestamp represents a timestamp value on the Ethereum chain always in UTC time zone. Recorded in unix seconds
func (Timestamp) MarshalJSONRPC ¶
func (Timestamp) MarshalText ¶
func (*Timestamp) UnmarshalText ¶
type Token ¶
type Token struct {
Name string `json:"name"`
Symbol string `json:"symbol"`
Address Address `json:"address"`
Decimals uint `json:"decimals"`
TotalSupply *big.Int `json:"total_supply"`
}
func (*Token) Amount ¶
func (t *Token) Amount(value int64) TokenAmount
type TokenAmount ¶
func (TokenAmount) Bytes ¶
func (t TokenAmount) Bytes() []byte
func (TokenAmount) Format ¶
func (t TokenAmount) Format(truncateDecimalCount uint) string
func (TokenAmount) String ¶
func (t TokenAmount) String() string
type TransactionType ¶
type TransactionType uint8
ENUM(
Legacy AccessList DynamicFee
)
const ( // TxTypeLegacy is a TransactionType of type Legacy. TxTypeLegacy TransactionType = iota // TxTypeAccessList is a TransactionType of type AccessList. TxTypeAccessList // TxTypeDynamicFee is a TransactionType of type DynamicFee. TxTypeDynamicFee )
func ParseTransactionType ¶
func ParseTransactionType(name string) (TransactionType, error)
ParseTransactionType attempts to convert a string to a TransactionType
func (TransactionType) String ¶
func (x TransactionType) String() string
String implements the Stringer interface.
func (*TransactionType) UnmarshalText ¶
func (b *TransactionType) UnmarshalText(text []byte) error
type TypeKind ¶
type TypeKind int
ENUM(
Boolean Address SignedInteger UnsignedInteger SignedFixedPoint UsignedFixedPoint FixedSizeBytes Bytes String FixedSizeArray Array Struct
Mappings )
const ( // TypeBoolean is a TypeKind of type Boolean. TypeBoolean TypeKind = iota // TypeAddress is a TypeKind of type Address. TypeAddress // TypeSignedInteger is a TypeKind of type SignedInteger. TypeSignedInteger // TypeUnsignedInteger is a TypeKind of type UnsignedInteger. TypeUnsignedInteger // TypeSignedFixedPoint is a TypeKind of type SignedFixedPoint. TypeSignedFixedPoint // TypeUsignedFixedPoint is a TypeKind of type UsignedFixedPoint. TypeUsignedFixedPoint // TypeFixedSizeBytes is a TypeKind of type FixedSizeBytes. TypeFixedSizeBytes // TypeBytes is a TypeKind of type Bytes. TypeBytes // TypeString is a TypeKind of type String. TypeString // TypeFixedSizeArray is a TypeKind of type FixedSizeArray. TypeFixedSizeArray // TypeArray is a TypeKind of type Array. TypeArray // TypeStruct is a TypeKind of type Struct. TypeStruct // TypeMappings is a TypeKind of type Mappings. TypeMappings )
func ParseTypeKind ¶
ParseTypeKind attempts to convert a string to a TypeKind
type Uint16Array ¶
type Uint16Array []uint16
func (Uint16Array) At ¶
func (a Uint16Array) At(index uint64, value interface{})
type Uint256 ¶
func (*Uint256) MarshalJSONRPC ¶
func (*Uint256) MarshalText ¶
func (*Uint256) UnmarshalText ¶
type Uint32Array ¶
type Uint32Array []uint32
func (Uint32Array) At ¶
func (a Uint32Array) At(index uint64, value interface{})
type Uint64Array ¶
type Uint64Array []uint64
func (Uint64Array) At ¶
func (a Uint64Array) At(index uint64, value interface{})
type Uint8Array ¶
type Uint8Array []uint8
func (Uint8Array) At ¶
func (a Uint8Array) At(index uint64, value interface{})
type UnsignedFixedPointType ¶
type UnsignedFixedPointType struct {
// BitsSize is the number of bites taken by this type, BitsSize / 8 = ByteSize, range of values is between 8 and 256 (inclusive) by step of 8
BitsSize uint
// ByteSize is the number of bytes taken by this type, ByteSize * 8 = BitsSize, range of values is between 1 and 32 (inclusive)
ByteSize uint
// Decimals represents the precision in decimals of this fixed type and will be between 0 and 80 (inclusive)
Decimals uint
}
func (UnsignedFixedPointType) IsDynamic ¶
func (t UnsignedFixedPointType) IsDynamic() bool
func (UnsignedFixedPointType) Kind ¶
func (t UnsignedFixedPointType) Kind() TypeKind
func (UnsignedFixedPointType) Name ¶
func (t UnsignedFixedPointType) Name() string
type UnsignedIntegerType ¶
type UnsignedIntegerType struct {
// BitsSize is the number of bites taken by this type, BitsSize / 8 = ByteSize, range of values is between 8 and 256 (inclusive) by step of 8
BitsSize uint
// ByteSize is the number of bytes taken by this type, ByteSize * 8 = BitsSize, range of values is between 1 and 32 (inclusive)
ByteSize uint
}
func (UnsignedIntegerType) IsDynamic ¶
func (t UnsignedIntegerType) IsDynamic() bool
func (UnsignedIntegerType) Kind ¶
func (t UnsignedIntegerType) Kind() TypeKind
func (UnsignedIntegerType) Name ¶
func (t UnsignedIntegerType) Name() string