httpclient

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: LGPL-3.0 Imports: 11 Imported by: 4

Documentation

Overview

Package httpclient provides an HTTP client to interact with the VeChainThor blockchain. It offers various methods to retrieve accounts, transactions, blocks, events, and other blockchain data through HTTP requests.

Index

Constants

View Source
const (
	BestRevision      = "best"
	FinalizedRevision = "finalized"
)

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrNot200Status = errors.New("not 200 status code")
)

Functions

This section is empty.

Types

type Client

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

Client represents the HTTP client for interacting with the VeChainThor blockchain. It manages communication via HTTP requests.

func New

func New(url string) *Client

New creates a new Client with the provided URL.

func NewWithHTTP

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

func (*Client) FilterEvents

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

FilterEvents filters events based on the provided event filter.

func (*Client) FilterTransfers

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

FilterTransfers filters transfer based on the provided transfer filter.

func (*Client) GetAccount

func (c *Client) GetAccount(addr *thor.Address, revision string) (*api.Account, error)

GetAccount retrieves the account details for the given address at the specified revision.

func (*Client) GetAccountCode

func (c *Client) GetAccountCode(addr *thor.Address, revision string) (*api.GetCodeResult, error)

GetAccountCode retrieves the contract code for the given address at the specified revision.

func (*Client) GetAccountStorage

func (c *Client) GetAccountStorage(addr *thor.Address, key *thor.Bytes32, revision string) (*api.GetStorageResult, error)

GetAccountStorage retrieves the storage value for the given address and key at the specified revision.

func (*Client) GetBlock

func (c *Client) GetBlock(blockID string) (*api.JSONCollapsedBlock, error)

GetBlock retrieves a block by its block ID.

func (*Client) GetExpandedBlock

func (c *Client) GetExpandedBlock(revision string) (*api.JSONExpandedBlock, error)

GetExpandedBlock retrieves an expanded block by its revision.

func (*Client) GetFeesHistory added in v2.3.0

func (c *Client) GetFeesHistory(blockCount uint32, newestBlock string, rewardPercentiles []float64) (*api.FeesHistory, error)

GetFeesHistory retrieves the fees history based on the block count and newest block.

func (*Client) GetFeesPriority added in v2.3.0

func (c *Client) GetFeesPriority() (*api.FeesPriority, error)

GetFeesPriority retrieves the suggested maxPriorityFeePerGas for a transaction to be included in the next blocks.

func (*Client) GetPeers

func (c *Client) GetPeers() ([]*api.PeerStats, error)

GetPeers retrieves the network peers connected to the node.

func (*Client) GetRawTransaction

func (c *Client) GetRawTransaction(txID *thor.Bytes32, head string, isPending bool) (*api.RawTransaction, error)

GetRawTransaction retrieves the raw transaction data by the transaction ID, along with options for head and pending status.

func (*Client) GetTransaction

func (c *Client) GetTransaction(txID *thor.Bytes32, head string, isPending bool) (*transactions.Transaction, error)

GetTransaction retrieves the transaction details by the transaction ID, along with options for head and pending status.

func (*Client) GetTransactionReceipt

func (c *Client) GetTransactionReceipt(txID *thor.Bytes32, head string) (*api.Receipt, error)

GetTransactionReceipt retrieves the receipt for the given transaction ID at the specified head.

func (*Client) GetTxPool added in v2.3.2

func (c *Client) GetTxPool(expanded bool, origin *thor.Address) (any, error)

GetTxPool retrieves transactions from the transaction pool.

func (*Client) GetTxPoolStatus added in v2.3.2

func (c *Client) GetTxPoolStatus() (*api.Status, error)

GetTxPoolStatus retrieves the current status of the transaction pool.

func (*Client) InspectClauses

func (c *Client) InspectClauses(calldata *api.BatchCallData, revision string) ([]*api.CallResult, error)

InspectClauses performs a clause inspection on batch call data at the specified revision.

func (*Client) RawHTTPGet

func (c *Client) RawHTTPGet(url string) ([]byte, int, error)

RawHTTPGet sends a raw HTTP GET request to the specified URL.

func (*Client) RawHTTPPost

func (c *Client) RawHTTPPost(url string, calldata any) ([]byte, int, error)

RawHTTPPost sends a raw HTTP POST request to the specified URL with the provided data.

func (*Client) SendTransaction

func (c *Client) SendTransaction(obj *api.RawTx) (*api.SendTxResult, error)

SendTransaction sends a raw transaction to the blockchain.

Jump to

Keyboard shortcuts

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