Documentation ¶
Index ¶
- Constants
- type AddressDecoder
- type AddressEncodeDecoder
- type AddressEncoder
- type Client
- func (client *Client) AccountBalance(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) AccountNonce(ctx context.Context, addr address.Address) (pack.U256, error)
- func (client *Client) LatestBlock(ctx context.Context) (pack.U64, error)
- func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) error
- func (client *Client) Tx(ctx context.Context, txID pack.Bytes) (account.Tx, pack.U64, error)
- type ClientOptions
- type GasEstimator
- type Tx
- func (tx Tx) From() address.Address
- func (tx Tx) Hash() pack.Bytes
- func (tx Tx) Nonce() pack.U256
- func (tx Tx) Payload() contract.CallData
- func (tx Tx) Serialize() (pack.Bytes, error)
- func (tx Tx) Sighashes() ([]pack.Bytes32, error)
- func (tx *Tx) Sign(signatures []pack.Bytes65, pubkey pack.Bytes) error
- func (tx Tx) To() address.Address
- func (tx Tx) Value() pack.U256
- type TxBuilder
Constants ¶
const ( // AuthorizationKey is the header key used for authorization AuthorizationKey = "Authorization" // DefaultClientRPCURL is the RPC URL used by default, to interact with the // filecoin lotus node. DefaultClientRPCURL = "http://127.0.0.1:1234/rpc/v0" // DefaultClientAuthToken is the auth token used to instantiate the lotus // client. A valid lotus auth token is required to write messages to the // filecoin storage. To do read-only queries, auth token is not required. DefaultClientAuthToken = "" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressDecoder ¶
type AddressDecoder struct{}
AddressDecoder implements the address.Decoder interface.
func (AddressDecoder) DecodeAddress ¶
func (addrDecoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error)
DecodeAddress implements the address.Decoder interface. It receives a human readable address and decodes it to an address represented by raw bytes.
type AddressEncodeDecoder ¶
type AddressEncodeDecoder struct { AddressEncoder AddressDecoder }
AddressEncodeDecoder implements the address.EncodeDecoder interface
func NewAddressEncodeDecoder ¶
func NewAddressEncodeDecoder() AddressEncodeDecoder
NewAddressEncodeDecoder constructs a new AddressEncodeDecoder.
type AddressEncoder ¶
type AddressEncoder struct{}
AddressEncoder implements the address.Encoder interface.
func (AddressEncoder) EncodeAddress ¶
func (encoder AddressEncoder) EncodeAddress(raw address.RawAddress) (address.Address, error)
EncodeAddress implements the address.Encoder interface. It receives a raw address and encodes it to a human-readable stringified address.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client holds options to connect to a filecoin lotus node, and the underlying RPC client instance.
func NewClient ¶
func NewClient(opts ClientOptions) (*Client, error)
NewClient creates and returns a new JSON-RPC client to the Filecoin node
func (*Client) AccountBalance ¶ added in v0.2.12
AccountBalance returns the account balancee for a given address.
func (*Client) AccountNonce ¶ added in v0.2.8
AccountNonce returns the current nonce of the account. This is the nonce to be used while building a new transaction.
func (*Client) LatestBlock ¶ added in v0.2.20
LatestBlock returns the block number at the current chain head.
type ClientOptions ¶
ClientOptions are used to parameterise the behaviour of the Client.
func DefaultClientOptions ¶
func DefaultClientOptions() ClientOptions
DefaultClientOptions returns ClientOptions with the default settings. These settings are valid for use with the default local deployment of the multichain. In production, the rpc-url and authentication token should be changed.
func (ClientOptions) WithAuthToken ¶
func (opts ClientOptions) WithAuthToken(authToken pack.String) ClientOptions
WithAuthToken returns a modified version of the options with the given authentication token.
func (ClientOptions) WithRPCURL ¶
func (opts ClientOptions) WithRPCURL(rpcURL pack.String) ClientOptions
WithRPCURL returns a modified version of the options with the given API rpc-url
type GasEstimator ¶ added in v0.2.8
type GasEstimator struct {
// contains filtered or unexported fields
}
A GasEstimator returns the gas fee cap and gas premium that is needed in order to confirm transactions with an estimated maximum delay of one block. In distributed networks that collectively build, sign, and submit transactions, it is important that all nodes in the network have reached consensus on these values.
func NewGasEstimator ¶ added in v0.2.8
func NewGasEstimator(client *Client, gasLimit int64) *GasEstimator
NewGasEstimator returns a simple gas estimator that fetches the ideal gas fee cap and gas premium for a filecoin transaction to be included in a block with minimal delay.
func (*GasEstimator) EstimateGas ¶ added in v0.2.9
EstimateGas returns an estimate of the current gas price (also known as gas premium) and gas cap. These numbers change with congestion. These estimates are often a little bit off, and this should be considered when using them.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a filecoin transaction, encapsulating a message and its signature.
func (Tx) From ¶
From returns the address that is sending the transaction. Generally, this is also the address that must sign the transaction.
func (Tx) Hash ¶
Hash returns the hash that uniquely identifies the transaction. Generally, hashes are irreversible hash functions that consume the content of the transaction.
func (Tx) Nonce ¶
Nonce returns the nonce used to order the transaction with respect to all other transactions signed and submitted by the sender.
func (Tx) Payload ¶
Payload returns arbitrary data that is associated with the transaction. Generally, this payload is used to send notes between external accounts, or invoke business logic on a contract.
func (Tx) Serialize ¶
Serialize the transaction into bytes. Generally, this is the format in which the transaction will be submitted by the client.
func (Tx) Sighashes ¶
Sighashes returns the digests that must be signed before the transaction can be submitted by the client.
func (*Tx) Sign ¶
Sign the transaction by injecting signatures for the required sighashes. The serialized public key used to sign the sighashes must also be specified.