Documentation
¶
Index ¶
- Constants
- type BaseFeeHistory
- type BaseFeePercentile
- type BusyThreshold
- type Client
- func (c *Client) GetBaseFeeHistory(ctx context.Context, chainID int64) (BaseFeeHistory, error)
- func (c *Client) GetBaseFeePercentile(ctx context.Context, chainID int64) (*BaseFeePercentile, error)
- func (c *Client) GetBusyThreshold(ctx context.Context, chainID int64) (*BusyThreshold, error)
- func (c *Client) GetSuggestedGasFees(ctx context.Context, chainID int64) (*SuggestedGasFees, error)
- type ClientOption
- type GasFeeLevel
- type SuggestedGasFees
Constants ¶
const ( // BaseURL is the base URL for Infura Gas API BaseURL = "https://gas.api.infura.io" // DefaultTimeout is the default HTTP client timeout DefaultTimeout = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseFeeHistory ¶
type BaseFeeHistory []string
BaseFeeHistory represents the response from the baseFeeHistory endpoint The API directly returns an array of strings
type BaseFeePercentile ¶
type BaseFeePercentile struct {
BaseFeePercentile string `json:"baseFeePercentile"`
}
BaseFeePercentile represents the response from the baseFeePercentile endpoint
type BusyThreshold ¶
type BusyThreshold struct {
BusyThreshold string `json:"busyThreshold"`
}
BusyThreshold represents the response from the busyThreshold endpoint
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the Infura Gas API client
func NewClient ¶
NewClient creates a new Infura Gas API client If apiKeySecret is empty, only API Key authentication will be used (API Key in URL path) If apiKeySecret is provided, Basic Auth will be used (API Key + Secret)
func NewClientWithAPIKey ¶
NewClientWithAPIKey creates a new client using only API Key (no secret) This uses the URL path authentication method: /v3/{apiKey}/networks/{chainId}/suggestedGasFees
func NewClientWithAPIKeyAndOptions ¶
func NewClientWithAPIKeyAndOptions(apiKey string, opts ...ClientOption) *Client
NewClientWithAPIKeyAndOptions creates a new client with only API Key and custom options
func NewClientWithOptions ¶
func NewClientWithOptions(apiKey, apiKeySecret string, opts ...ClientOption) *Client
NewClientWithOptions creates a new client with custom options If apiKeySecret is empty, only API Key authentication will be used
func (*Client) GetBaseFeeHistory ¶
GetBaseFeeHistory retrieves base fee history for a given chain ID If API Key Secret is provided, uses Basic Auth: /networks/{chainId}/baseFeeHistory If only API Key is provided, uses URL path auth: /v3/{apiKey}/networks/{chainId}/baseFeeHistory The API returns an array of strings directly
func (*Client) GetBaseFeePercentile ¶
func (c *Client) GetBaseFeePercentile(ctx context.Context, chainID int64) (*BaseFeePercentile, error)
GetBaseFeePercentile retrieves base fee percentile for a given chain ID If API Key Secret is provided, uses Basic Auth: /networks/{chainId}/baseFeePercentile If only API Key is provided, uses URL path auth: /v3/{apiKey}/networks/{chainId}/baseFeePercentile
func (*Client) GetBusyThreshold ¶
GetBusyThreshold retrieves busy threshold for a given chain ID If API Key Secret is provided, uses Basic Auth: /networks/{chainId}/busyThreshold If only API Key is provided, uses URL path auth: /v3/{apiKey}/networks/{chainId}/busyThreshold
func (*Client) GetSuggestedGasFees ¶
GetSuggestedGasFees retrieves suggested gas fees for a given chain ID If API Key Secret is provided, uses Basic Auth: /networks/{chainId}/suggestedGasFees If only API Key is provided, uses URL path auth: /v3/{apiKey}/networks/{chainId}/suggestedGasFees
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that configures a Client
func WithDebug ¶
func WithDebug(debug bool) ClientOption
WithDebug enables debug mode to print HTTP request and response details
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client
func WithRateLimit ¶
func WithRateLimit(ratePerSecond float64, burst int) ClientOption
WithRateLimit sets a rate limiter for the client rate is the number of requests per second burst is the maximum number of requests that can be made in a single burst Example: WithRateLimit(10, 20) allows 10 requests per second with a burst of 20
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout sets a custom timeout
type GasFeeLevel ¶
type GasFeeLevel struct {
SuggestedMaxPriorityFeePerGas string `json:"suggestedMaxPriorityFeePerGas"`
SuggestedMaxFeePerGas string `json:"suggestedMaxFeePerGas"`
MinWaitTimeEstimate int64 `json:"minWaitTimeEstimate"`
MaxWaitTimeEstimate int64 `json:"maxWaitTimeEstimate"`
}
GasFeeLevel represents a gas fee level (low, medium, or high)
type SuggestedGasFees ¶
type SuggestedGasFees struct {
Low GasFeeLevel `json:"low"`
Medium GasFeeLevel `json:"medium"`
High GasFeeLevel `json:"high"`
EstimatedBaseFee string `json:"estimatedBaseFee"`
NetworkCongestion float64 `json:"networkCongestion"`
LatestPriorityFeeRange []string `json:"latestPriorityFeeRange"`
HistoricalPriorityFeeRange []string `json:"historicalPriorityFeeRange"`
HistoricalBaseFeeRange []string `json:"historicalBaseFeeRange"`
PriorityFeeTrend string `json:"priorityFeeTrend"`
BaseFeeTrend string `json:"baseFeeTrend"`
}
SuggestedGasFees represents the response from the suggestedGasFees endpoint