Documentation ¶
Index ¶
- Constants
- func Bytes2Hex(d []byte) string
- func FromHex(s string) []byte
- func Hex2Bytes(str string) []byte
- func IsHexAddress(s string) bool
- type Address
- func (a Address) Bytes() []byte
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hex() string
- func (a Address) ImplementsGraphQLType(name string) bool
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Scan(src interface{}) error
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a *Address) UnmarshalGraphQL(input interface{}) error
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- func (a Address) Value() (driver.Value, error)
- type Block
- type Error
- type RequestResult
- func (pointer *RequestResult) ToBigInt() (*big.Int, error)
- func (pointer *RequestResult) ToBlock() (*Block, error)
- func (pointer *RequestResult) ToBoolean() (bool, error)
- func (pointer *RequestResult) ToComplexString() (types.ComplexString, error)
- func (pointer *RequestResult) ToInt() (int64, error)
- func (pointer *RequestResult) ToSignTransactionResponse() (*SignTransactionResponse, error)
- func (pointer *RequestResult) ToString() (string, error)
- func (pointer *RequestResult) ToStringArray() ([]string, error)
- func (pointer *RequestResult) ToSyncingResponse() (*SyncingResponse, error)
- func (pointer *RequestResult) ToTransactionReceipt() (*TransactionReceipt, error)
- func (pointer *RequestResult) ToTransactionResponse() (*TransactionResponse, error)
- func (pointer *RequestResult) UnMarshalResult(result interface{}) error
- type RequestTransactionParameters
- type SHHPostParameters
- type SignTransactionResponse
- type SignedTransactionParams
- type SyncingResponse
- type TransactionLogs
- type TransactionParameters
- type TransactionReceipt
- type TransactionResponse
Constants ¶
const AddressLength = 20
Variables ¶
This section is empty.
Functions ¶
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func (Address) Format ¶
Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.
func (Address) ImplementsGraphQLType ¶
ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (*Address) UnmarshalGraphQL ¶
UnmarshalGraphQL unmarshals the provided GraphQL query data.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Block ¶
type Block struct { Number *big.Int `json:"number"` Hash string `json:"hash"` ParentHash string `json:"parentHash"` Author string `json:"author,omitempty"` Miner string `json:"miner,omitempty"` Size *big.Int `json:"size"` GasUsed *big.Int `json:"gasUsed"` Nonce *big.Int `json:"nonce"` Timestamp *big.Int `json:"timestamp"` }
func (*Block) UnmarshalJSON ¶
*
- How to un-marshal the block struct using the Big.Int rather than the
- `complexReturn` type.
type RequestResult ¶
type RequestResult struct { ID int `json:"id"` Version string `json:"jsonrpc"` Result json.RawMessage `json:"result"` Error *Error `json:"error,omitempty"` Data string `json:"data,omitempty"` }
func (*RequestResult) ToBlock ¶
func (pointer *RequestResult) ToBlock() (*Block, error)
func (*RequestResult) ToBoolean ¶
func (pointer *RequestResult) ToBoolean() (bool, error)
func (pointer *RequestResult) ToComplexIntResponse() (types.ComplexIntResponse, error) {
if err := pointer.checkResponse(); err != nil { return types.ComplexIntResponse(0), err } result := (pointer).Result.(interface{}) var hex string switch v := result.(type) { //Testrpc returns a float64 case float64: hex = strconv.FormatFloat(v, 'E', 16, 64) break default: hex = result.(string) } cleaned := strings.TrimPrefix(hex, "0x") return types.ComplexIntResponse(cleaned), nil
}
func (*RequestResult) ToComplexString ¶
func (pointer *RequestResult) ToComplexString() (types.ComplexString, error)
func (*RequestResult) ToInt ¶
func (pointer *RequestResult) ToInt() (int64, error)
func (*RequestResult) ToSignTransactionResponse ¶
func (pointer *RequestResult) ToSignTransactionResponse() (*SignTransactionResponse, error)
func (*RequestResult) ToString ¶
func (pointer *RequestResult) ToString() (string, error)
func (*RequestResult) ToStringArray ¶
func (pointer *RequestResult) ToStringArray() ([]string, error)
func (*RequestResult) ToSyncingResponse ¶
func (pointer *RequestResult) ToSyncingResponse() (*SyncingResponse, error)
func (*RequestResult) ToTransactionReceipt ¶
func (pointer *RequestResult) ToTransactionReceipt() (*TransactionReceipt, error)
func (*RequestResult) ToTransactionResponse ¶
func (pointer *RequestResult) ToTransactionResponse() (*TransactionResponse, error)
func (*RequestResult) UnMarshalResult ¶
func (pointer *RequestResult) UnMarshalResult(result interface{}) error
type RequestTransactionParameters ¶
type RequestTransactionParameters struct { From string `json:"from"` To string `json:"to,omitempty"` Nonce string `json:"nonce,omitempty"` Gas string `json:"gas,omitempty"` GasPrice string `json:"gasPrice,omitempty"` Value string `json:"value,omitempty"` Data string `json:"data,omitempty"` }
RequestTransactionParameters JSON
type SHHPostParameters ¶
type SignTransactionResponse ¶
type SignTransactionResponse struct { Raw types.ComplexString `json:"raw"` Transaction SignedTransactionParams `json:"tx"` }
type SignedTransactionParams ¶
type SignedTransactionParams struct { Gas *big.Int `json:gas` GasPrice *big.Int `json:gasPrice` Hash string `json:hash` Input string `json:input` Nonce *big.Int `json:nonce` S string `json:s` R string `json:r` V *big.Int `json:v` To string `json:to` Value *big.Int `json:value` }
func (*SignedTransactionParams) UnmarshalJSON ¶
func (sp *SignedTransactionParams) UnmarshalJSON(data []byte) error
type SyncingResponse ¶
type TransactionLogs ¶
type TransactionLogs struct { Address string `json:"address"` Topics []string `json:"topics"` Data string `json:"data"` BlockNumber *big.Int `json:"blockNumber"` TransactionHash string `json:"transactionHash"` TransactionIndex *big.Int `json:"transactionIndex"` BlockHash string `json:"blockHash"` LogIndex *big.Int `json:"logIndex"` Removed bool `json:"removed"` }
func (*TransactionLogs) UnmarshalJSON ¶
func (r *TransactionLogs) UnmarshalJSON(data []byte) error
type TransactionParameters ¶
type TransactionParameters struct { From string To string Nonce *big.Int Gas *big.Int GasPrice *big.Int Value *big.Int Data types.ComplexString }
TransactionParameters GO transaction to make more easy controll the parameters
func (*TransactionParameters) Transform ¶
func (params *TransactionParameters) Transform() *RequestTransactionParameters
Transform the GO transactions parameters to json style
type TransactionReceipt ¶
type TransactionReceipt struct { TransactionHash string `json:"transactionHash"` TransactionIndex *big.Int `json:"transactionIndex"` BlockHash string `json:"blockHash"` BlockNumber *big.Int `json:"blockNumber"` From string `json:"from"` To string `json:"to"` CumulativeGasUsed *big.Int `json:"cumulativeGasUsed"` GasUsed *big.Int `json:"gasUsed"` ContractAddress string `json:"contractAddress"` Logs []TransactionLogs `json:"logs"` LogsBloom string `json:"logsBloom"` Root string `json:"string"` Status bool `json:"status"` }
func (*TransactionReceipt) UnmarshalJSON ¶
func (r *TransactionReceipt) UnmarshalJSON(data []byte) error
type TransactionResponse ¶
type TransactionResponse struct { Hash string `json:"hash"` Nonce *big.Int `json:"nonce"` BlockHash string `json:"blockHash"` BlockNumber *big.Int `json:"blockNumber"` TransactionIndex *big.Int `json:"transactionIndex"` From string `json:"from"` To string `json:"to"` Input string `json:"input"` Value *big.Int `json:"value"` GasPrice *big.Int `json:"gasPrice,omitempty"` Gas *big.Int `json:"gas,omitempty"` Data types.ComplexString `json:"data,omitempty"` }
func (*TransactionResponse) UnmarshalJSON ¶
func (t *TransactionResponse) UnmarshalJSON(data []byte) error