Documentation ¶
Overview ¶
Package client provides a Go client for the Flow Access gRPC API.
The Access API provides a set of methods that can be used to submit transactions and read state from Flow. This client is compatible with the Access API implemented by the Access Node role, as well as the mock Access API exposed by the Flow Emulator.
The full Access API specification is here: https://github.com/onflow/flow/blob/master/docs/access-api-spec.md
Index ¶
- type BlockEvents
- type Client
- func (c *Client) Close() error
- func (c *Client) ExecuteScriptAtBlockHeight(ctx context.Context, height uint64, script []byte, arguments []cadence.Value) (cadence.Value, error)
- func (c *Client) ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, ...) (cadence.Value, error)
- func (c *Client) ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments []cadence.Value) (cadence.Value, error)
- func (c *Client) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)
- func (c *Client) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, error)
- func (c *Client) GetBlockByID(ctx context.Context, blockID flow.Identifier) (*flow.Block, error)
- func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.BlockHeader, error)
- func (c *Client) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier) (*flow.BlockHeader, error)
- func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error)
- func (c *Client) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier) ([]BlockEvents, error)
- func (c *Client) GetEventsForHeightRange(ctx context.Context, query EventRangeQuery) ([]BlockEvents, error)
- func (c *Client) GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, error)
- func (c *Client) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.BlockHeader, error)
- func (c *Client) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.Transaction, error)
- func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier) (*flow.TransactionResult, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) SendTransaction(ctx context.Context, tx flow.Transaction) error
- type EventRangeQuery
- type RPCClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockEvents ¶
type BlockEvents struct { BlockID flow.Identifier Height uint64 Events []flow.Event }
BlockEvents are the events that occurred in a specific block.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a gRPC Client for the Flow Access API.
func New ¶
func New(addr string, opts ...grpc.DialOption) (*Client, error)
New initializes a Flow client with the default gRPC provider.
An error will be returned if the host is unreachable.
func NewFromRPCClient ¶
NewFromRPCClient initializes a Flow client using a pre-configured gRPC provider.
func (*Client) ExecuteScriptAtBlockHeight ¶
func (c *Client) ExecuteScriptAtBlockHeight( ctx context.Context, height uint64, script []byte, arguments []cadence.Value, ) (cadence.Value, error)
ExecuteScriptAtBlockHeight executes a ready-only Cadence script against the execution state at the given block height.
func (*Client) ExecuteScriptAtBlockID ¶
func (c *Client) ExecuteScriptAtBlockID( ctx context.Context, blockID flow.Identifier, script []byte, arguments []cadence.Value, ) (cadence.Value, error)
ExecuteScriptAtBlockID executes a ready-only Cadence script against the execution state at the block with the given ID.
func (*Client) ExecuteScriptAtLatestBlock ¶
func (c *Client) ExecuteScriptAtLatestBlock( ctx context.Context, script []byte, arguments []cadence.Value) (cadence.Value, error)
ExecuteScriptAtLatestBlock executes a read-only Cadence script against the latest sealed execution state.
func (*Client) GetAccount ¶
GetAccount gets an account by address.
func (*Client) GetBlockByHeight ¶
GetBlockByHeight gets a full block by height.
func (*Client) GetBlockByID ¶
GetBlockByID gets a full block by ID.
func (*Client) GetBlockHeaderByHeight ¶
func (c *Client) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.BlockHeader, error)
GetBlockHeaderByHeight gets a block header by height.
func (*Client) GetBlockHeaderByID ¶
func (c *Client) GetBlockHeaderByID(ctx context.Context, blockID flow.Identifier) (*flow.BlockHeader, error)
GetBlockHeaderByID gets a block header by ID.
func (*Client) GetCollection ¶
func (c *Client) GetCollection(ctx context.Context, colID flow.Identifier) (*flow.Collection, error)
GetCollection gets a collection by ID.
func (*Client) GetEventsForBlockIDs ¶
func (c *Client) GetEventsForBlockIDs( ctx context.Context, eventType string, blockIDs []flow.Identifier, ) ([]BlockEvents, error)
GetEventsForBlockIDs retrieves events with the given type from the specified block IDs.
func (*Client) GetEventsForHeightRange ¶
func (c *Client) GetEventsForHeightRange(ctx context.Context, query EventRangeQuery) ([]BlockEvents, error)
GetEventsForHeightRange retrieves events for all sealed blocks between the start and end block heights (inclusive) with the given type.
func (*Client) GetLatestBlock ¶
GetLatestBlock gets the full payload of the latest sealed or unsealed block.
func (*Client) GetLatestBlockHeader ¶
func (c *Client) GetLatestBlockHeader( ctx context.Context, isSealed bool, ) (*flow.BlockHeader, error)
GetLatestBlockHeader gets the latest sealed or unsealed block header.
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.Transaction, error)
GetTransaction gets a transaction by ID.
func (*Client) GetTransactionResult ¶
func (c *Client) GetTransactionResult(ctx context.Context, txID flow.Identifier) (*flow.TransactionResult, error)
GetTransactionResult gets the result of a transaction.
type EventRangeQuery ¶
type EventRangeQuery struct { // The event type to search for. If empty, no filtering by type is done. Type string // The block height to begin looking for events StartHeight uint64 // The block height to end looking for events (inclusive) EndHeight uint64 }
EventRangeQuery defines a query for Flow events.
type RPCClient ¶
type RPCClient interface { access.AccessAPIClient }
An RPCClient is an RPC client for the Flow Access API.