Documentation ¶
Index ¶
- Constants
- Variables
- func NewBigInt(x uint64) *hexutil.Big
- func NewBigIntByRaw(x *big.Int) *hexutil.Big
- func NewBytes(input []byte) hexutil.Bytes
- func NewUint(x uint) *hexutil.Uint
- func NewUint64(x uint64) *hexutil.Uint64
- type AccountPendingTransactions
- type Address
- func MustNew(base32OrHex string, networkID ...uint32) Address
- func MustNewFromBase32(base32Str string) (address Address)
- func MustNewFromBytes(hexAddress []byte, networkID ...uint32) (address Address)
- func MustNewFromCommon(commonAddress common.Address, networkID ...uint32) (address Address)
- func MustNewFromHex(hexAddressStr string, networkID ...uint32) (val Address)
- func New(base32OrHex string, networkID ...uint32) (Address, error)
- func NewFromBase32(base32Str string) (cfxAddress Address, err error)
- func NewFromBytes(hexAddress []byte, networkID ...uint32) (val Address, err error)
- func NewFromCommon(commonAddress common.Address, networkID ...uint32) (val Address, err error)
- func NewFromHex(hexAddressStr string, networkID ...uint32) (val Address, err error)
- func (a *Address) CompleteByClient(client networkIDGetter) error
- func (a *Address) CompleteByNetworkID(networkID uint32) error
- func (a *Address) DecodeRLP(r *rlp.Stream) error
- func (a Address) EncodeRLP(w io.Writer) error
- func (a *Address) Equals(target *Address) bool
- func (a *Address) GetAddressType() AddressType
- func (a *Address) GetBody() Body
- func (a *Address) GetChecksum() Checksum
- func (a *Address) GetHexAddress() string
- func (a *Address) GetMappedEVMSpaceAddress() common.Address
- func (a *Address) GetNetworkID() uint32
- func (a *Address) GetNetworkType() NetworkType
- func (a *Address) GetShortenAddress(isTail4Char ...bool) string
- func (a *Address) IsValid() bool
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) MustGetBase32Address() string
- func (a *Address) MustGetCommonAddress() common.Address
- func (a *Address) MustGetVerboseBase32Address() string
- func (a Address) String() string
- func (a *Address) ToCommon() (address common.Address, networkID uint32, err error)
- func (a *Address) ToHex() (hexAddressStr string, networkID uint32)
- func (a *Address) UnmarshalJSON(data []byte) error
- func (a *Address) UnmarshalText(data []byte) error
- type AddressType
- type Bloom
- type Body
- type Checksum
- type Epoch
- type EpochOrBlockHash
- func (e *EpochOrBlockHash) IsBlockHash() (*common.Hash, bool, bool)
- func (e *EpochOrBlockHash) IsEpoch() (*Epoch, bool)
- func (e EpochOrBlockHash) MarshalJSON() ([]byte, error)
- func (e EpochOrBlockHash) MarshalText() ([]byte, error)
- func (e *EpochOrBlockHash) String() string
- func (e *EpochOrBlockHash) UnmarshalJSON(data []byte) error
- type EvmSpaceOutcome
- type Hash
- type Log
- type LogFilter
- type NativeSpaceOutcome
- type NetworkType
- type NonceType
- type PendingReason
- type SpaceType
- type StorageChange
- type Transaction
- type TransactionOutcome
- type TransactionReceipt
- type TransactionStatus
- type VersionByte
- type WebsocketEpochResponse
Constants ¶
const ( NetworkTypeMainnetPrefix NetworkType = "cfx" NetworkTypeTestNetPrefix NetworkType = "cfxtest" NetowrkTypeMainnetID uint32 = 1029 NetworkTypeTestnetID uint32 = 1 )
Variables ¶
var (
ErrorBodyLen = errors.New("Body length must be 34")
)
Functions ¶
func NewBigIntByRaw ¶
NewBigIntByRaw creates a hexutil.big with specified big.int value.
Types ¶
type AccountPendingTransactions ¶
type AccountPendingTransactions struct { PendingTransactions []Transaction `json:"pendingTransactions"` // type maybe string/Pending FirstTxStatus *TransactionStatus `json:"firstTxStatus"` PendingCount hexutil.Uint64 `json:"pendingCount"` }
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func MustNew ¶
MustNew create conflux address by base32 string or hex40 string, if base32OrHex is base32 and networkID is setted it will check if networkID match, it will painc if error occured.
func MustNewFromBase32 ¶
MustNewFromBase32 creates address by base32 string and panic if error
func MustNewFromBytes ¶
MustNewFromBytes creates an address from hexAddress byte slice with networkID and panic if error
func MustNewFromCommon ¶
MustNewFromCommon creates an address from common.Address with networkID and panic if error
func MustNewFromHex ¶
MustNewFromHex creates address by hex address string with networkID and panic if error
func New ¶
New create conflux address by base32 string or hex40 string, if base32OrHex is base32 and networkID is passed it will create cfx Address use networkID.
func NewFromBase32 ¶
NewFromBase32 creates address by base32 string
func NewFromBytes ¶
NewFromBytes creates an address from hexAddress byte slice with networkID
func NewFromCommon ¶
NewFromCommon creates an address from common.Address with networkID
func NewFromHex ¶
NewFromHex creates address by hex address string with networkID If not pass networkID, it will be auto completed when it could be obtained form context.
func (*Address) CompleteByClient ¶
CompleteByClient will set networkID by client.GetNetworkID() if a.networkID not be 0
func (*Address) CompleteByNetworkID ¶
CompleteByNetworkID will set networkID if current networkID isn't 0
func (*Address) GetAddressType ¶
func (a *Address) GetAddressType() AddressType
GetAddressType returuns address type
func (*Address) GetHexAddress ¶
GetHexAddress returns hex format address and panic if error
func (*Address) GetMappedEVMSpaceAddress ¶
GetMappedEVMSpaceAddress calculate CFX space address's mapped EVM address, which is the last 20 bytes of cfx address's keccak256 hash
func (*Address) GetNetworkID ¶
GetNetworkID returns networkID and panic if error
func (*Address) GetNetworkType ¶
func (a *Address) GetNetworkType() NetworkType
GetNetworkType returns network type
func (*Address) GetShortenAddress ¶
GetShortenAddress returns shorten string for display in dapp. When isTail4Char is 'true', the result will be like 'cfx:aat…sa4w', otherwise 'cfx:aat…5m81sa4w'
func (Address) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Address) MustGetBase32Address ¶
MustGetBase32Address returns base32 string of address which doesn't include address type
func (*Address) MustGetCommonAddress ¶
MustGetCommonAddress returns common address and panic if error
func (*Address) MustGetVerboseBase32Address ¶
MustGetVerboseBase32Address returns base32 string of address with address type
func (*Address) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*Address) UnmarshalText ¶
type AddressType ¶
type AddressType string
const ( AddressTypeBuiltin AddressType = "builtin" AddressTypeUser AddressType = "user" AddressTypeContract AddressType = "contract" AddressTypeNull AddressType = "null" AddressTypeUnknown AddressType = "unknown" )
func CalcAddressType ¶
func CalcAddressType(hexAddress []byte) (AddressType, error)
CalcAddressType calculate address type of hexAddress
func (AddressType) String ¶
func (a AddressType) String() string
func (AddressType) ToByte ¶
func (a AddressType) ToByte() (byte, error)
ToByte returns byte represents of address type according to CIP-37
type Body ¶
type Body [34]byte
func NewBodyByHexAddress ¶
func NewBodyByHexAddress(vrsByte VersionByte, hexAddress []byte) (b Body, err error)
NewBodyByHexAddress convert concat of version type and hex address to 5 bits slice
func NewBodyByString ¶
NewBodyByString creates body by base32 string which contains version byte and hex address
func (Body) ToHexAddress ¶
func (b Body) ToHexAddress() (vrsType VersionByte, hexAddress []byte, err error)
ToHexAddress decode bits5 array to version byte and hex address
type Checksum ¶
type Checksum [8]byte
func CalcChecksum ¶
func CalcChecksum(nt NetworkType, body Body) (c Checksum, err error)
CalcChecksum calculates checksum by network type and body
type Epoch ¶
type Epoch struct {
// contains filtered or unexported fields
}
Epoch represents an epoch in Conflux.
var ( EpochEarliest *Epoch = &Epoch{"earliest", nil} EpochLatestCheckpoint *Epoch = &Epoch{"latest_checkpoint", nil} EpochLatestConfirmed *Epoch = &Epoch{"latest_confirmed", nil} EpochLatestState *Epoch = &Epoch{"latest_state", nil} EpochLatestMined *Epoch = &Epoch{"latest_mined", nil} EpochLatestFinalized *Epoch = &Epoch{"latest_finalized", nil} )
Const epoch definitions
func NewEpochNumber ¶
NewEpochNumber creates an instance of Epoch with specified number.
func NewEpochNumberBig ¶
NewEpochNumberBig creates an instance of Epoch with specified big number.
func NewEpochNumberUint64 ¶
NewEpochNumberUint64 creates an instance of Epoch with specified uint64 number.
func (Epoch) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Epoch) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type EpochOrBlockHash ¶
type EpochOrBlockHash struct {
// contains filtered or unexported fields
}
func NewEpochOrBlockHashWithBlockHash ¶
func NewEpochOrBlockHashWithBlockHash(blockHash Hash, requirePivot ...bool) *EpochOrBlockHash
NewEpochOrBlockHashWithBlockHash creates an instance of Epoch with specified block hash.
func NewEpochOrBlockHashWithEpoch ¶
func NewEpochOrBlockHashWithEpoch(epoch *Epoch) *EpochOrBlockHash
NewEpochOrBlockHashWithEpoch creates an instance of Epoch with specified epoch.
func (*EpochOrBlockHash) IsBlockHash ¶
func (e *EpochOrBlockHash) IsBlockHash() (*common.Hash, bool, bool)
IsBlockHash returns "block hash" and "require pivot" if it is blockhash, and the 3rd return value represents if is block hash.
func (*EpochOrBlockHash) IsEpoch ¶
func (e *EpochOrBlockHash) IsEpoch() (*Epoch, bool)
IsEpoch returns epoch if it is epoch, and the 2rd return value represents if is epoch.
func (EpochOrBlockHash) MarshalJSON ¶
func (e EpochOrBlockHash) MarshalJSON() ([]byte, error)
func (EpochOrBlockHash) MarshalText ¶
func (e EpochOrBlockHash) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*EpochOrBlockHash) String ¶
func (e *EpochOrBlockHash) String() string
String implements the fmt.Stringer interface
func (*EpochOrBlockHash) UnmarshalJSON ¶
func (e *EpochOrBlockHash) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type EvmSpaceOutcome ¶
type EvmSpaceOutcome uint8
const ( EVM_SPACE_FAIL EvmSpaceOutcome = iota EVM_SPACE_SUCCESS EVM_SPACE_SKIPPED = 0xff )
type Hash ¶
type Hash string
func (Hash) ToCommonHash ¶
ToCommonHash converts hash to common.Hash
func (*Hash) UnmarshalJSON ¶
type Log ¶
type Log struct { Address Address `json:"address"` Topics []Hash `json:"topics"` Data hexutil.Bytes `json:"data"` BlockHash *Hash `json:"blockHash,omitempty"` EpochNumber *hexutil.Big `json:"epochNumber,omitempty"` TransactionHash *Hash `json:"transactionHash,omitempty"` TransactionIndex *hexutil.Big `json:"transactionIndex,omitempty"` LogIndex *hexutil.Big `json:"logIndex,omitempty"` TransactionLogIndex *hexutil.Big `json:"transactionLogIndex,omitempty"` Space *SpaceType `json:"space,omitempty"` }
Log represents the event in a smart contract
type LogFilter ¶
type LogFilter struct { FromEpoch *Epoch `json:"fromEpoch,omitempty"` ToEpoch *Epoch `json:"toEpoch,omitempty"` FromBlock *hexutil.Big `json:"fromBlock,omitempty"` ToBlock *hexutil.Big `json:"toBlock,omitempty"` BlockHashes []Hash `json:"blockHashes,omitempty"` Address []Address `json:"address,omitempty"` Topics [][]Hash `json:"topics,omitempty"` }
func (*LogFilter) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type NativeSpaceOutcome ¶
type NativeSpaceOutcome uint8
const ( NATIVE_SPACE_SUCCESS NativeSpaceOutcome = iota NATIVE_SPACE_EXCEPTION_WITH_NONCE_BUMPING // gas fee charged NATIVE_SPACE_EXCEPTION_WITHOUT_NONCE_BUMPING // no gas fee charged )
type NetworkType ¶
type NetworkType string
func NewNetowrkType ¶
func NewNetowrkType(netType string) (NetworkType, error)
NewNetowrkType creates network type by string
func NewNetworkTypeByID ¶
func NewNetworkTypeByID(networkID uint32) NetworkType
NewNetworkTypeByID creates network type by network ID
func (NetworkType) String ¶
func (n NetworkType) String() string
func (NetworkType) ToNetworkID ¶
func (n NetworkType) ToNetworkID() (uint32, error)
ToNetworkID returns network ID
type PendingReason ¶
type PendingReason string
const ( PENDING_REASON_FUTURE_NONCE PendingReason = "futureNonce" PENDING_REASON_NOT_ENOUGH_CASH PendingReason = "notEnoughCash" PENDING_REASON_OLD_EPOCH_HEIGHT PendingReason = "oldEpochHeight" PENDING_REASON_OUTDATED_STATUS PendingReason = "outdatedStatus" )
type StorageChange ¶
type StorageChange struct { Address Address `json:"address"` /// Number of storage collateral units to deposit / refund (absolute value). Collaterals hexutil.Uint64 `json:"collaterals"` }
StorageChange represents storage change information of the address
type Transaction ¶
type Transaction struct { // Space *string `json:"space,omitempty"` //currently it is always "nil", so comment it now and uncomment it if need later Hash Hash `json:"hash"` Nonce *hexutil.Big `json:"nonce"` BlockHash *Hash `json:"blockHash"` TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` From Address `json:"from"` To *Address `json:"to"` Value *hexutil.Big `json:"value"` GasPrice *hexutil.Big `json:"gasPrice"` Gas *hexutil.Big `json:"gas"` ContractCreated *Address `json:"contractCreated"` Data string `json:"data"` StorageLimit *hexutil.Big `json:"storageLimit"` EpochHeight *hexutil.Big `json:"epochHeight"` ChainID *hexutil.Big `json:"chainId"` Status *hexutil.Uint64 `json:"status"` //signature V *hexutil.Big `json:"v"` R *hexutil.Big `json:"r"` S *hexutil.Big `json:"s"` }
type TransactionOutcome ¶
type TransactionOutcome uint8
const ( TRANSACTION_OUTCOME_SUCCESS TransactionOutcome = iota TRANSACTION_OUTCOME_FAILURE TRANSACTION_OUTCOME_SKIPPED )
type TransactionReceipt ¶
type TransactionReceipt struct { TransactionHash Hash `json:"transactionHash"` Index hexutil.Uint64 `json:"index"` BlockHash Hash `json:"blockHash"` EpochNumber *hexutil.Uint64 `json:"epochNumber"` From Address `json:"from"` To *Address `json:"to"` GasUsed *hexutil.Big `json:"gasUsed"` AccumulatedGasUsed *hexutil.Big `json:"accumulatedGasUsed,omitempty"` GasFee *hexutil.Big `json:"gasFee"` ContractCreated *Address `json:"contractCreated"` Logs []Log `json:"logs"` LogsBloom Bloom `json:"logsBloom"` StateRoot Hash `json:"stateRoot"` OutcomeStatus hexutil.Uint64 `json:"outcomeStatus"` TxExecErrorMsg *string `json:"txExecErrorMsg"` // Whether gas costs were covered by the sponsor. GasCoveredBySponsor bool `json:"gasCoveredBySponsor"` // Whether storage costs were covered by the sponsor. StorageCoveredBySponsor bool `json:"storageCoveredBySponsor"` // The amount of storage collateralized by the sender. StorageCollateralized hexutil.Uint64 `json:"storageCollateralized"` // Storage collaterals released during the execution of the transaction. StorageReleased []StorageChange `json:"storageReleased"` Space *SpaceType `json:"space,omitempty"` }
TransactionReceipt represents the transaction execution result in Conflux. it is the response from conflux node when sending rpc request, such as cfx_getTransactionReceipt
func (*TransactionReceipt) DecodeRLP ¶
func (tr *TransactionReceipt) DecodeRLP(r *rlp.Stream) error
DecodeRLP implements the rlp.Decoder interface.
func (TransactionReceipt) EncodeRLP ¶
func (tr TransactionReceipt) EncodeRLP(w io.Writer) error
EncodeRLP implements the rlp.Encoder interface.
func (*TransactionReceipt) GetOutcomeType ¶
func (r *TransactionReceipt) GetOutcomeType() (TransactionOutcome, error)
func (*TransactionReceipt) MustGetOutcomeType ¶
func (r *TransactionReceipt) MustGetOutcomeType() TransactionOutcome
type TransactionStatus ¶
type TransactionStatus struct {
// contains filtered or unexported fields
}
func (*TransactionStatus) IsPending ¶
func (ts *TransactionStatus) IsPending() (bool, PendingReason)
func (TransactionStatus) MarshalJSON ¶
func (ts TransactionStatus) MarshalJSON() ([]byte, error)
func (TransactionStatus) String ¶
func (ts TransactionStatus) String() string
func (*TransactionStatus) UnmarshalJSON ¶
func (ts *TransactionStatus) UnmarshalJSON(data []byte) error
type VersionByte ¶
type VersionByte struct { TypeBits uint8 // current is constant 0, it's different with AddressType defined in address_type.go AddressType uint8 SizeBits uint8 }
func CalcVersionByte ¶
func CalcVersionByte(hexAddress []byte) (versionByte VersionByte, err error)
func NewVersionByte ¶
func NewVersionByte(b byte) (vt VersionByte)
NewVersionByte creates version byte by byte
type WebsocketEpochResponse ¶
type WebsocketEpochResponse struct { EpochHashesOrdered []Hash `json:"epochHashesOrdered"` EpochNumber *hexutil.Big `json:"epochNumber"` }
WebsocketEpochResponse represents result of epoch websocket subscription