thorclient

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2025 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents the VeChainThor client, allowing communication over HTTP and WebSocket.

func New

func New(url string) *Client

New creates a new Client using the provided HTTP URL.

func NewWithHTTP

func NewWithHTTP(url string, c *http.Client) *Client

NewWithHTTP creates a new Client using the provided HTTP URL and HTTP client.

func NewWithWS

func NewWithWS(url string) (*Client, error)

NewWithWS creates a new Client using the provided HTTP and WebSocket URLs. Returns an error if the WebSocket connection fails.

func (*Client) Account

func (c *Client) Account(addr *thor.Address, opts ...Option) (*accounts.Account, error)

Account retrieves an account from the blockchain based on the provided address and options.

func (*Client) AccountCode

func (c *Client) AccountCode(addr *thor.Address, opts ...Option) (*accounts.GetCodeResult, error)

AccountCode retrieves the account code for a given address.

func (*Client) AccountStorage

func (c *Client) AccountStorage(addr *thor.Address, key *thor.Bytes32, opts ...Option) (*accounts.GetStorageResult, error)

AccountStorage retrieves the storage value for a given address and key.

func (*Client) Block

func (c *Client) Block(revision string) (blocks *blocks.JSONCollapsedBlock, err error)

Block retrieves a block by its revision.

func (*Client) ChainTag

func (c *Client) ChainTag() (byte, error)

ChainTag retrieves the chain tag from the genesis block.

func (*Client) ExpandedBlock

func (c *Client) ExpandedBlock(revision string) (blocks *blocks.JSONExpandedBlock, err error)

ExpandedBlock retrieves an expanded block by its revision.

func (*Client) FilterEvents

func (c *Client) FilterEvents(req *events.EventFilter) ([]events.FilteredEvent, error)

FilterEvents filters events based on the provided filter request.

func (*Client) FilterTransfers

func (c *Client) FilterTransfers(req *transfers.TransferFilter) ([]*transfers.FilteredTransfer, error)

FilterTransfers filters transfers based on the provided filter request.

func (*Client) InspectClauses

func (c *Client) InspectClauses(calldata *accounts.BatchCallData, opts ...Option) ([]*accounts.CallResult, error)

InspectClauses inspects the clauses of a batch call data and returns the call results.

func (*Client) InspectTxClauses

func (c *Client) InspectTxClauses(tx *tx.Transaction, senderAddr *thor.Address, opts ...Option) ([]*accounts.CallResult, error)

InspectTxClauses inspects the clauses of a transaction and returns the call results. It accepts both signed and unsigned transactions.

func (*Client) Peers

func (c *Client) Peers() ([]*node.PeerStats, error)

Peers retrieves the list of connected peers.

func (*Client) RawHTTPClient

func (c *Client) RawHTTPClient() *httpclient.Client

RawHTTPClient returns the underlying HTTP client.

func (*Client) RawTransaction

func (c *Client) RawTransaction(id *thor.Bytes32, opts ...Option) (*transactions.RawTransaction, error)

RawTransaction retrieves the raw transaction data by its ID.

func (*Client) RawWSClient

func (c *Client) RawWSClient() *wsclient.Client

RawWSClient returns the underlying WebSocket client.

func (*Client) SendRawTransaction

func (c *Client) SendRawTransaction(rlpTx []byte) (*transactions.SendTxResult, error)

SendRawTransaction sends a raw RLP-encoded transaction to the blockchain.

func (*Client) SendTransaction

func (c *Client) SendTransaction(tx *tx.Transaction) (*transactions.SendTxResult, error)

SendTransaction sends a signed transaction to the blockchain.

func (*Client) SubscribeBeats2

func (c *Client) SubscribeBeats2(pos string) (*common.Subscription[*subscriptions.Beat2Message], error)

SubscribeBeats2 subscribes to Beat2 message updates over WebSocket.

func (*Client) SubscribeBlocks

func (c *Client) SubscribeBlocks(pos string) (*common.Subscription[*subscriptions.BlockMessage], error)

SubscribeBlocks subscribes to block updates over WebSocket.

func (*Client) SubscribeEvents

func (c *Client) SubscribeEvents(pos string, filter *subscriptions.EventFilter) (*common.Subscription[*subscriptions.EventMessage], error)

SubscribeEvents subscribes to event updates over WebSocket.

func (*Client) SubscribeTransfers

SubscribeTransfers subscribes to transfer updates over WebSocket.

func (*Client) SubscribeTxPool

func (c *Client) SubscribeTxPool(txID *thor.Bytes32) (*common.Subscription[*subscriptions.PendingTxIDMessage], error)

SubscribeTxPool subscribes to pending transaction updates over WebSocket.

func (*Client) Transaction

func (c *Client) Transaction(id *thor.Bytes32, opts ...Option) (*transactions.Transaction, error)

Transaction retrieves a transaction by its ID.

func (*Client) TransactionReceipt

func (c *Client) TransactionReceipt(id *thor.Bytes32, opts ...Option) (*transactions.Receipt, error)

TransactionReceipt retrieves the receipt for a transaction by its ID.

type Option

type Option func(*getOptions)

Option represents a functional option for customizing client requests.

func Pending

func Pending() Option

Pending returns an Option to specify that the client should fetch pending results.

func Revision

func Revision(revision string) Option

Revision returns an Option to specify the revision for requests.

Directories

Path Synopsis
Package httpclient provides an HTTP client to interact with the VeChainThor blockchain.
Package httpclient provides an HTTP client to interact with the VeChainThor blockchain.
Package wsclient provides a WebSocket client for subscribing to various VeChainThor blockchain events.
Package wsclient provides a WebSocket client for subscribing to various VeChainThor blockchain events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL