Documentation
¶
Overview ¶
Package bitquery provides functions to query blockchain contract creation information using the Ethereum blockchain. It primarily focuses on retrieving the transaction hash and block height of smart contract creations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContractCreationInfo ¶
type ContractCreationInfo struct { // Data contains the nested structure of contract calls and their details. Data struct { // SmartContractCreation wraps the actual array of smart contract calls. SmartContractCreation struct { // SmartContractCalls is an array of smart contract call details. SmartContractCalls []struct { // Transaction contains the hash of the transaction. Transaction struct { Hash string `json:"hash"` } `json:"transaction"` // Block contains the height of the block. Block struct { Height int `json:"height"` } `json:"block"` } `json:"smartContractCalls"` } `json:"smartContractCreation"` } `json:"data"` }
ContractCreationInfo holds data about smart contract creation events, including transaction hash and block height.
func (*ContractCreationInfo) GetBlockHeight ¶
func (c *ContractCreationInfo) GetBlockHeight() int
GetBlockHeight returns the block height of the first smart contract call if available, otherwise zero.
func (*ContractCreationInfo) GetTransactionHash ¶
func (c *ContractCreationInfo) GetTransactionHash() string
GetTransactionHash returns the transaction hash of the first smart contract call if available, otherwise an empty string.
type Options ¶
type Options struct { // Endpoint specifies the URL of the blockchain data service. // This is where the bitquery client will send its requests. Endpoint string `mapstructure:"endpoint" yaml:"endpoint" json:"endpoint"` // Key is the authentication key required by the blockchain data service. // This key is used to authorize the client's requests. Key string `mapstructure:"key" yaml:"key" json:"key"` }
Options contains configuration settings for the bitquery client. These settings specify how the client connects to the blockchain data provider.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider represents a client for the blockchain data service, configured with options and capable of making requests.
func NewProvider ¶
NewProvider initializes and returns a new Provider instance. It validates the provided Options to ensure necessary configurations are set.
Returns an error if the Options are nil, or if essential options like Endpoint or Key are not configured.
func (*Provider) GetContractCreationInfo ¶
func (b *Provider) GetContractCreationInfo(ctx context.Context, query map[string]string) (*ContractCreationInfo, error)
GetContractCreationInfo sends a query to the blockchain data service to retrieve contract creation information such as the transaction hash and block height.
This method accepts a context (for cancellation and deadlines) and a query map defining the parameters of the query. It returns a pointer to ContractCreationInfo containing the requested data, or an error if the request fails, the response status is not OK, or the response cannot be decoded.
func (*Provider) QueryContractCreationBlockAndTxHash ¶
func (b *Provider) QueryContractCreationBlockAndTxHash(ctx context.Context, networkGroup string, address common.Address) (*ContractCreationInfo, error)
QueryContractCreationBlockAndTxHash queries the blockchain for contract creation information by network group and address, returning the ContractCreationInfo.