Documentation ¶
Index ¶
- Constants
- Variables
- func BigCmp(a, b BigInt) int
- func BigDivFloat(num, den BigInt) float64
- func DecodeHexString(s string) ([]byte, error)
- func DecodeHexStringTrimSpace(s string) ([]byte, error)
- func DecodeRLP(data []byte) (interface{}, error)
- func EncodeRLP(val interface{}) ([]byte, error)
- func EthAddressFromPubKey(pubk []byte) ([]byte, error)
- func EthBloomSet(f EthBytes, data []byte)
- func IsEthAddress(addr address.Address) bool
- func One[R any](r R, err error) R
- func RecoverSignature(sig typescrypto.Signature) (EthBigInt, EthBigInt, EthBigInt, error)
- func SetEip155ChainID(val int)
- type Actor
- type ActorV4
- type ActorV5
- type BigInt
- type ChainMsg
- type EthAddress
- func CastEthAddress(b []byte) (EthAddress, error)
- func EthAddressFromFilecoinAddress(addr address.Address) (EthAddress, error)
- func GetContractEthAddressFromCode(sender EthAddress, salt [32]byte, initcode []byte) (EthAddress, error)
- func ParseEthAddress(s string) (EthAddress, error)
- func TryEthAddressFromFilecoinAddress(addr address.Address, allowID bool) (EthAddress, bool, error)
- type EthAddressList
- type EthBigInt
- type EthBlock
- type EthBytes
- type EthCall
- type EthFeeHistory
- type EthFeeHistoryParams
- type EthFilterID
- type EthFilterResult
- type EthFilterSpec
- type EthHash
- type EthHashList
- type EthLog
- type EthNonce
- type EthSubscribeParams
- type EthSubscriptionID
- type EthSubscriptionParams
- type EthSubscriptionResponse
- type EthTopicSpec
- type EthTx
- type EthTxArgs
- func (tx *EthTxArgs) HashedOriginalRlpMsg() ([]byte, error)
- func (tx *EthTxArgs) Sender() (address.Address, error)
- func (tx *EthTxArgs) Signature() (*typescrypto.Signature, error)
- func (tx *EthTxArgs) ToRlpSignedMsg() ([]byte, error)
- func (tx *EthTxArgs) ToRlpUnsignedMsg() ([]byte, error)
- func (tx *EthTxArgs) ToSignedMessage() (*SignedMessage, error)
- func (tx *EthTxArgs) ToUnsignedMessage(from address.Address) (*Message, error)
- func (tx *EthTxArgs) TxHash() (EthHash, error)
- type EthTxReceipt
- type EthUint64
- type FIL
- func (f FIL) Format(s fmt.State, ch rune)
- func (f FIL) MarshalJSON() ([]byte, error)
- func (f FIL) MarshalText() (text []byte, err error)
- func (f FIL) Nano() string
- func (f FIL) Short() string
- func (f FIL) String() string
- func (f FIL) Unitless() string
- func (f *FIL) UnmarshalJSON(by []byte) error
- func (f *FIL) UnmarshalText(text []byte) error
- type Message
- func (m *Message) ChainLength() int
- func (m *Message) Cid() cid.Cid
- func (m *Message) EqualCall(o *Message) bool
- func (m *Message) Equals(o *Message) bool
- func (t *Message) MarshalCBOR(w io.Writer) error
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) RequiredFunds() abi.TokenAmount
- func (m *Message) Serialize() ([]byte, error)
- func (m *Message) SerializeWithCid() (cid.Cid, []byte, error)
- func (m *Message) SigningBytes(sigType crypto.SigType) ([]byte, error)
- func (m *Message) String() string
- func (m *Message) ToStorageBlock() (blocks.Block, error)
- func (t *Message) UnmarshalCBOR(r io.Reader) (err error)
- func (m *Message) VMMessage() *Message
- func (m *Message) ValidForBlockInclusion(minGas int64, version network.Version) error
- type RawMessage
- type RawSignedMessage
- type SignedMessage
- func (smsg *SignedMessage) ChainLength() int
- func (smsg *SignedMessage) Cid() cid.Cid
- func (t *SignedMessage) MarshalCBOR(w io.Writer) error
- func (sm *SignedMessage) MarshalJSON() ([]byte, error)
- func (smsg *SignedMessage) Serialize() ([]byte, error)
- func (smsg *SignedMessage) SerializeWithCid() (cid.Cid, []byte, error)
- func (smsg *SignedMessage) String() string
- func (smsg *SignedMessage) ToStorageBlock() (blocks.Block, error)
- func (t *SignedMessage) UnmarshalCBOR(r io.Reader) (err error)
- func (smsg *SignedMessage) VMMessage() *Message
Constants ¶
const ( EthAddressLength = 20 EthHashLength = 32 )
const Eip1559TxType = 2
const EthBloomSize = 2048
const MessageVersion = 0
Variables ¶
var ( AttoFil = NewInt(1) FemtoFil = BigMul(AttoFil, NewInt(1000)) PicoFil = BigMul(FemtoFil, NewInt(1000)) NanoFil = BigMul(PicoFil, NewInt(1000)) )
var ( EmptyEthBloom = [EthBloomSize / 8]byte{} FullEthBloom = [EthBloomSize / 8]byte{} EmptyEthHash = EthHash{} EmptyUncleHash = One(ParseEthHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")) // Keccak-256 of an RLP of an empty array EmptyRootHash = One(ParseEthHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")) // Keccak-256 hash of the RLP of null EmptyEthInt = EthUint64(0) EmptyEthNonce = [8]byte{0, 0, 0, 0, 0, 0, 0, 0} )
var Eip155ChainID = 314
mainnet
var EmptyInt = BigInt{}
var ErrActorNotFound = errors.New("actor not found")
var ErrInvalidAddress = errors.New("invalid Filecoin Eth address")
var (
EthBigIntZero = EthBigInt{Int: big.Zero().Int}
)
var TotalFilecoinInt = FromFil(params.FilBase)
var ZeroAddress address.Address = One(address.NewFromString("f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a"))
var ZeroFIL = fbig.NewInt(0)
Functions ¶
func BigDivFloat ¶
func DecodeHexString ¶
func EthAddressFromPubKey ¶
EthAddressFromPubKey returns the Ethereum address corresponding to an uncompressed secp256k1 public key.
func EthBloomSet ¶
func IsEthAddress ¶
func IsEthAddress(addr address.Address) bool
func RecoverSignature ¶
func SetEip155ChainID ¶
func SetEip155ChainID(val int)
Types ¶
type Actor ¶
type Actor = ActorV5
func (*Actor) IncrementSeqNum ¶
func (t *Actor) IncrementSeqNum()
IncrementSeqNum increments the seq number.
type ActorV4 ¶
type ActorV4 struct { // Code is a CID of the VM code for this actor's implementation (or a constant for actors implemented in Go code). // Code may be nil for an uninitialized actor (which exists because it has received a balance). Code cid.Cid // Head is the CID of the root of the actor's state tree. Head cid.Cid // Nonce is the number expected on the next message from this actor. // Messages are processed in strict, contiguous order. Nonce uint64 // Balance is the amount of attoFIL in the actor's account. Balance abi.TokenAmount }
Actor is the central abstraction of entities in the system.
Both individual accounts, as well as contracts (user & system level) are represented as actors. An actor has the following core functionality implemented on a system level: - track a Filecoin balance, using the `Balance` field - execute code stored in the `Code` field - read & write memory - replay protection, using the `Nonce` field
Value sent to a non-existent address will be tracked as an empty actor that has a Balance but nil Code and Memory. You must nil check Code cids before comparing them.
More specific capabilities for individual accounts or contract specific must be implemented inside the code.
Not safe for concurrent access.
type ActorV5 ¶
type ActorV5 struct { // Identifies the type of actor (string coded as a CID), see `chain/actors/actors.go`. Code cid.Cid Head cid.Cid Nonce uint64 Balance BigInt // Deterministic Address Address *address.Address }
Actor State for state tree version 5
type EthAddress ¶
type EthAddress [EthAddressLength]byte
func CastEthAddress ¶
func CastEthAddress(b []byte) (EthAddress, error)
CastEthAddress interprets bytes as an EthAddress, performing some basic checks.
func EthAddressFromFilecoinAddress ¶
func EthAddressFromFilecoinAddress(addr address.Address) (EthAddress, error)
func GetContractEthAddressFromCode ¶
func GetContractEthAddressFromCode(sender EthAddress, salt [32]byte, initcode []byte) (EthAddress, error)
func ParseEthAddress ¶
func ParseEthAddress(s string) (EthAddress, error)
ParseEthAddress parses an Ethereum address from a hex string.
func TryEthAddressFromFilecoinAddress ¶
func TryEthAddressFromFilecoinAddress(addr address.Address, allowID bool) (EthAddress, bool, error)
This API assumes that if an ID address is passed in, it doesn't have an equivalent delegated address
func (EthAddress) IsMaskedID ¶
func (ea EthAddress) IsMaskedID() bool
func (EthAddress) MarshalJSON ¶
func (ea EthAddress) MarshalJSON() ([]byte, error)
func (EthAddress) String ¶
func (ea EthAddress) String() string
func (EthAddress) ToFilecoinAddress ¶
func (ea EthAddress) ToFilecoinAddress() (address.Address, error)
func (*EthAddress) UnmarshalJSON ¶
func (ea *EthAddress) UnmarshalJSON(b []byte) error
type EthAddressList ¶
type EthAddressList []EthAddress
EthAddressSpec represents a list of addresses. The JSON decoding must treat a string as equivalent to an array with one value, for example "0x8888f1f195afa192cfee86069858" must be decoded as [ "0x8888f1f195afa192cfee86069858" ]
func (*EthAddressList) UnmarshalJSON ¶
func (e *EthAddressList) UnmarshalJSON(b []byte) error
type EthBigInt ¶
EthBigInt represents a large integer whose zero value serializes to "0x0".
func (EthBigInt) MarshalJSON ¶
func (*EthBigInt) UnmarshalJSON ¶
type EthBlock ¶
type EthBlock struct { Hash EthHash `json:"hash"` ParentHash EthHash `json:"parentHash"` Sha3Uncles EthHash `json:"sha3Uncles"` Miner EthAddress `json:"miner"` StateRoot EthHash `json:"stateRoot"` TransactionsRoot EthHash `json:"transactionsRoot"` ReceiptsRoot EthHash `json:"receiptsRoot"` LogsBloom EthBytes `json:"logsBloom"` Difficulty EthUint64 `json:"difficulty"` TotalDifficulty EthUint64 `json:"totalDifficulty"` Number EthUint64 `json:"number"` GasLimit EthUint64 `json:"gasLimit"` GasUsed EthUint64 `json:"gasUsed"` Timestamp EthUint64 `json:"timestamp"` Extradata EthBytes `json:"extraData"` MixHash EthHash `json:"mixHash"` Nonce EthNonce `json:"nonce"` BaseFeePerGas EthBigInt `json:"baseFeePerGas"` Size EthUint64 `json:"size"` // can be []EthTx or []string depending on query params Transactions []interface{} `json:"transactions"` Uncles []EthHash `json:"uncles"` }
func NewEthBlock ¶
type EthBytes ¶
type EthBytes []byte
EthBytes represent arbitrary bytes. A nil or empty slice serializes to "0x".
func (EthBytes) MarshalJSON ¶
func (*EthBytes) UnmarshalJSON ¶
type EthCall ¶
type EthCall struct { From *EthAddress `json:"from"` To *EthAddress `json:"to"` Gas EthUint64 `json:"gas"` GasPrice EthBigInt `json:"gasPrice"` Value EthBigInt `json:"value"` Data EthBytes `json:"data"` }
func (*EthCall) UnmarshalJSON ¶
type EthFeeHistory ¶
type EthFeeHistoryParams ¶
type EthFeeHistoryParams struct { BlkCount EthUint64 NewestBlkNum string RewardPercentiles *[]float64 }
EthFeeHistoryParams handles raw jsonrpc params for eth_feeHistory
func (EthFeeHistoryParams) MarshalJSON ¶
func (e EthFeeHistoryParams) MarshalJSON() ([]byte, error)
func (*EthFeeHistoryParams) UnmarshalJSON ¶
func (e *EthFeeHistoryParams) UnmarshalJSON(b []byte) error
type EthFilterID ¶
type EthFilterID EthHash
func (EthFilterID) MarshalJSON ¶
func (h EthFilterID) MarshalJSON() ([]byte, error)
func (EthFilterID) String ¶
func (h EthFilterID) String() string
func (*EthFilterID) UnmarshalJSON ¶
func (h *EthFilterID) UnmarshalJSON(b []byte) error
type EthFilterResult ¶
type EthFilterResult struct {
Results []interface{}
}
FilterResult represents the response from executing a filter: a list of block hashes, a list of transaction hashes or a list of logs This is a union type. Only one field will be populated. The JSON encoding must produce an array of the populated field.
func (EthFilterResult) MarshalJSON ¶
func (h EthFilterResult) MarshalJSON() ([]byte, error)
func (*EthFilterResult) UnmarshalJSON ¶
func (h *EthFilterResult) UnmarshalJSON(b []byte) error
type EthFilterSpec ¶
type EthFilterSpec struct { // Interpreted as an epoch or one of "latest" for last mined block, "earliest" for first, // "pending" for not yet committed messages. // Optional, default: "latest". FromBlock *string `json:"fromBlock,omitempty"` // Interpreted as an epoch or one of "latest" for last mined block, "earliest" for first, // "pending" for not yet committed messages. // Optional, default: "latest". ToBlock *string `json:"toBlock,omitempty"` // Actor address or a list of addresses from which event logs should originate. // Optional, default nil. // The JSON decoding must treat a string as equivalent to an array with one value, for example // "0x8888f1f195afa192cfee86069858" must be decoded as [ "0x8888f1f195afa192cfee86069858" ] Address EthAddressList `json:"address"` // List of topics to be matched. // Optional, default: empty list Topics EthTopicSpec `json:"topics"` // Restricts event logs returned to those emitted from messages contained in this tipset. // If BlockHash is present in in the filter criteria, then neither FromBlock nor ToBlock are allowed. // Added in EIP-234 BlockHash *EthHash `json:"blockHash,omitempty"` }
type EthHash ¶
type EthHash [EthHashLength]byte
func EthHashFromCid ¶
func EthHashFromTxBytes ¶
func ParseEthHash ¶
func (EthHash) MarshalJSON ¶
func (EthHash) ToCid ¶
func (h EthHash) ToCid() cid.Cid
Should ONLY be used for blocks and Filecoin messages. Eth transactions expect a different hashing scheme.
func (*EthHash) UnmarshalJSON ¶
type EthHashList ¶
type EthHashList []EthHash
EthHashList represents a list of EthHashes. The JSON decoding treats string values as equivalent to arrays with one value.
func (*EthHashList) UnmarshalJSON ¶
func (e *EthHashList) UnmarshalJSON(b []byte) error
type EthLog ¶
type EthLog struct { // Address is the address of the actor that produced the event log. Address EthAddress `json:"address"` // Data is the value of the event log, excluding topics Data EthBytes `json:"data"` // List of topics associated with the event log. Topics []EthHash `json:"topics"` // Indicates whether the log was removed due to a chain reorganization. Removed bool `json:"removed"` // LogIndex is the index of the event log in the sequence of events produced by the message execution. // (this is the index in the events AMT on the message receipt) LogIndex EthUint64 `json:"logIndex"` // TransactionIndex is the index in the tipset of the transaction that produced the event log. // The index corresponds to the sequence of messages produced by ChainGetParentMessages TransactionIndex EthUint64 `json:"transactionIndex"` // TransactionHash is the hash of the RLP message that produced the event log. TransactionHash EthHash `json:"transactionHash"` // BlockHash is the hash of the tipset containing the message that produced the log. BlockHash EthHash `json:"blockHash"` // BlockNumber is the epoch of the tipset containing the message. BlockNumber EthUint64 `json:"blockNumber"` }
EthLog represents the results of an event filter execution.
type EthNonce ¶
type EthNonce [8]byte
func (EthNonce) MarshalJSON ¶
func (*EthNonce) UnmarshalJSON ¶
type EthSubscribeParams ¶
type EthSubscribeParams struct { EventType string Params *EthSubscriptionParams }
EthSubscribeParams handles raw jsonrpc params for eth_subscribe
func (EthSubscribeParams) MarshalJSON ¶
func (e EthSubscribeParams) MarshalJSON() ([]byte, error)
func (*EthSubscribeParams) UnmarshalJSON ¶
func (e *EthSubscribeParams) UnmarshalJSON(b []byte) error
type EthSubscriptionID ¶
type EthSubscriptionID EthHash
An opaque identifier generated by the Lotus node to refer to an active subscription.
func (EthSubscriptionID) MarshalJSON ¶
func (h EthSubscriptionID) MarshalJSON() ([]byte, error)
func (EthSubscriptionID) String ¶
func (h EthSubscriptionID) String() string
func (*EthSubscriptionID) UnmarshalJSON ¶
func (h *EthSubscriptionID) UnmarshalJSON(b []byte) error
type EthSubscriptionParams ¶
type EthSubscriptionParams struct { // List of topics to be matched. // Optional, default: empty list Topics EthTopicSpec `json:"topics,omitempty"` // Actor address or a list of addresses from which event logs should originate. // Optional, default nil. // The JSON decoding must treat a string as equivalent to an array with one value, for example // "0x8888f1f195afa192cfee86069858" must be decoded as [ "0x8888f1f195afa192cfee86069858" ] Address EthAddressList `json:"address"` }
type EthSubscriptionResponse ¶
type EthSubscriptionResponse struct { // The persistent identifier for the subscription which can be used to unsubscribe. SubscriptionID EthSubscriptionID `json:"subscription"` // The object matching the subscription. This may be a Block (tipset), a Transaction (message) or an EthLog Result interface{} `json:"result"` }
type EthTopicSpec ¶
type EthTopicSpec []EthHashList
TopicSpec represents a specification for matching by topic. An empty spec means all topics will be matched. Otherwise topics are matched conjunctively in the first dimension of the slice and disjunctively in the second dimension. Topics are matched in order. An event log with topics [A, B] will be matched by the following topic specs: [] "all" [[A]] "A in first position (and anything after)" [nil, [B] ] "anything in first position AND B in second position (and anything after)" [[A], [B]] "A in first position AND B in second position (and anything after)" [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position (and anything after)"
The JSON decoding must treat string values as equivalent to arrays with one value, for example { "A", [ "B", "C" ] } must be decoded as [ [ A ], [ B, C ] ]
type EthTx ¶
type EthTx struct { ChainID EthUint64 `json:"chainId"` Nonce EthUint64 `json:"nonce"` Hash EthHash `json:"hash"` BlockHash *EthHash `json:"blockHash"` BlockNumber *EthUint64 `json:"blockNumber"` TransactionIndex *EthUint64 `json:"transactionIndex"` From EthAddress `json:"from"` To *EthAddress `json:"to"` Value EthBigInt `json:"value"` Type EthUint64 `json:"type"` Input EthBytes `json:"input"` Gas EthUint64 `json:"gas"` MaxFeePerGas EthBigInt `json:"maxFeePerGas"` MaxPriorityFeePerGas EthBigInt `json:"maxPriorityFeePerGas"` AccessList []EthHash `json:"accessList"` V EthBigInt `json:"v"` R EthBigInt `json:"r"` S EthBigInt `json:"s"` }
func EthTxFromSignedEthMessage ¶
func EthTxFromSignedEthMessage(smsg *SignedMessage) (EthTx, error)
EthTxFromSignedEthMessage does NOT populate: - BlockHash - BlockNumber - TransactionIndex - From - Hash
func (*EthTx) ToEthTxArgs ¶
type EthTxArgs ¶
type EthTxArgs struct { ChainID int `json:"chainId"` Nonce int `json:"nonce"` To *EthAddress `json:"to"` Value big.Int `json:"value"` MaxFeePerGas big.Int `json:"maxFeePerGas"` MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"` GasLimit int `json:"gasLimit"` Input []byte `json:"input"` V big.Int `json:"v"` R big.Int `json:"r"` S big.Int `json:"s"` }
func ParseEthTxArgs ¶
func (*EthTxArgs) HashedOriginalRlpMsg ¶
func (*EthTxArgs) ToRlpSignedMsg ¶
func (*EthTxArgs) ToRlpUnsignedMsg ¶
func (*EthTxArgs) ToSignedMessage ¶
func (tx *EthTxArgs) ToSignedMessage() (*SignedMessage, error)
func (*EthTxArgs) ToUnsignedMessage ¶
type EthTxReceipt ¶
type EthTxReceipt struct { TransactionHash EthHash `json:"transactionHash"` TransactionIndex EthUint64 `json:"transactionIndex"` BlockHash EthHash `json:"blockHash"` BlockNumber EthUint64 `json:"blockNumber"` From EthAddress `json:"from"` To *EthAddress `json:"to"` // Logs // LogsBloom StateRoot EthHash `json:"root"` Status EthUint64 `json:"status"` ContractAddress *EthAddress `json:"contractAddress"` CumulativeGasUsed EthUint64 `json:"cumulativeGasUsed"` GasUsed EthUint64 `json:"gasUsed"` EffectiveGasPrice EthBigInt `json:"effectiveGasPrice"` LogsBloom EthBytes `json:"logsBloom"` Logs []EthLog `json:"logs"` Type EthUint64 `json:"type"` }
type EthUint64 ¶
type EthUint64 uint64
func EthUint64FromBytes ¶
Parse a uint64 from big-endian encoded bytes.
func EthUint64FromHex ¶
func (EthUint64) MarshalJSON ¶
func (*EthUint64) UnmarshalJSON ¶
UnmarshalJSON should be able to parse these types of input: 1. a JSON string containing a hex-encoded uint64 starting with 0x 2. a JSON string containing an uint64 in decimal 3. a string containing an uint64 in decimal
type FIL ¶
type FIL BigInt
func MustParseFIL ¶
func (FIL) MarshalJSON ¶
func (FIL) MarshalText ¶
func (*FIL) UnmarshalJSON ¶
func (*FIL) UnmarshalText ¶
type Message ¶
type Message struct { Version uint64 To address.Address From address.Address // When receiving a message from a user account the nonce in // the message must match the expected nonce in the from actor. // This prevents replay attacks. Nonce uint64 Value abi.TokenAmount GasLimit int64 GasFeeCap abi.TokenAmount GasPremium abi.TokenAmount Method abi.MethodNum Params []byte }
func DecodeMessage ¶
func (*Message) ChainLength ¶
func (*Message) MarshalJSON ¶
func (*Message) RequiredFunds ¶
func (m *Message) RequiredFunds() abi.TokenAmount
func (*Message) SerializeWithCid ¶
func (*Message) SigningBytes ¶
type RawMessage ¶
type RawMessage Message
type RawSignedMessage ¶
type RawSignedMessage SignedMessage
type SignedMessage ¶
SignedMessage contains a message and its signature
func (*SignedMessage) Cid ¶
func (smsg *SignedMessage) Cid() cid.Cid
func (*SignedMessage) MarshalCBOR ¶
func (t *SignedMessage) MarshalCBOR(w io.Writer) error
func (*SignedMessage) MarshalJSON ¶
func (sm *SignedMessage) MarshalJSON() ([]byte, error)
func (*SignedMessage) Serialize ¶
func (smsg *SignedMessage) Serialize() ([]byte, error)
Serialize return message binary
func (*SignedMessage) SerializeWithCid ¶
func (smsg *SignedMessage) SerializeWithCid() (cid.Cid, []byte, error)
Serialize return message binary
func (*SignedMessage) String ¶
func (smsg *SignedMessage) String() string
String return message json string
func (*SignedMessage) ToStorageBlock ¶
func (smsg *SignedMessage) ToStorageBlock() (blocks.Block, error)
func (*SignedMessage) UnmarshalCBOR ¶
func (t *SignedMessage) UnmarshalCBOR(r io.Reader) (err error)
func (*SignedMessage) VMMessage ¶
func (smsg *SignedMessage) VMMessage() *Message