blockfrost

package
v0.46.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPaginationCount = 100
	MaxPaginationCount     = 100
	DefaultPaginationPage  = 1
	PaginationOrderAsc     = "asc"
	PaginationOrderDesc    = "desc"
)

Variables

View Source
var (
	ErrInvalidAddress      = errors.New("invalid address")
	ErrInvalidBlockID      = errors.New("invalid block id")
	ErrBlockNotFound       = errors.New("block not found")
	ErrEpochNotFound       = errors.New("epoch not found")
	ErrAssetNotFound       = errors.New("asset not found")
	ErrDRepNotFound        = errors.New("drep not found")
	ErrInvalidTransaction  = errors.New("invalid transaction")
	ErrMempoolUnavailable  = errors.New("mempool unavailable")
	ErrMempoolFull         = errors.New("mempool full")
	ErrTransactionNotFound = errors.New("transaction not found")
	ErrInvalidStakeAddress = errors.New("invalid stake address")
)
View Source
var ErrInvalidPaginationParameters = errors.New(
	"invalid pagination parameters",
)

Functions

func SetPaginationHeaders

func SetPaginationHeaders(
	w http.ResponseWriter,
	totalItems int,
	params PaginationParams,
)

SetPaginationHeaders sets Blockfrost pagination headers.

Types

type AccountAssociatedAddressInfo added in v0.46.0

type AccountAssociatedAddressInfo struct {
	Address string
}

AccountAssociatedAddressInfo holds a payment address associated with a stake key.

type AccountAssociatedAddressResponse added in v0.46.0

type AccountAssociatedAddressResponse struct {
	Address string `json:"address"`
}

AccountAssociatedAddressResponse represents a stake account associated payment address.

type AccountDelegationHistoryInfo added in v0.46.0

type AccountDelegationHistoryInfo struct {
	ActiveEpoch int32
	TxHash      string
	Amount      string
	PoolID      string
}

AccountDelegationHistoryInfo holds a stake-account delegation history row.

type AccountDelegationHistoryResponse added in v0.46.0

type AccountDelegationHistoryResponse struct {
	ActiveEpoch int32  `json:"active_epoch"`
	TxHash      string `json:"tx_hash"`
	Amount      string `json:"amount"`
	PoolID      string `json:"pool_id"`
}

AccountDelegationHistoryResponse represents a stake-account delegation history row.

type AccountInfo added in v0.46.0

type AccountInfo struct {
	StakeAddress       string
	Active             bool
	ActiveEpoch        *int64
	ControlledAmount   string
	RewardsSum         string
	WithdrawalsSum     string
	ReservesSum        string
	TreasurySum        string
	WithdrawableAmount string
	PoolID             *string
}

AccountInfo holds stake-account data needed by the API.

type AccountRegistrationHistoryInfo added in v0.46.0

type AccountRegistrationHistoryInfo struct {
	TxHash string
	Action string
}

AccountRegistrationHistoryInfo holds a stake-account registration history row.

type AccountRegistrationHistoryResponse added in v0.46.0

type AccountRegistrationHistoryResponse struct {
	TxHash string `json:"tx_hash"`
	Action string `json:"action"`
}

AccountRegistrationHistoryResponse represents a stake-account registration history row.

type AccountResponse added in v0.46.0

type AccountResponse struct {
	StakeAddress       string  `json:"stake_address"`
	Active             bool    `json:"active"`
	ActiveEpoch        *int64  `json:"active_epoch"`
	ControlledAmount   string  `json:"controlled_amount"`
	RewardsSum         string  `json:"rewards_sum"`
	WithdrawalsSum     string  `json:"withdrawals_sum"`
	ReservesSum        string  `json:"reserves_sum"`
	TreasurySum        string  `json:"treasury_sum"`
	WithdrawableAmount string  `json:"withdrawable_amount"`
	PoolID             *string `json:"pool_id"`
}

AccountResponse represents a Blockfrost stake account.

type AccountRewardHistoryInfo added in v0.46.0

type AccountRewardHistoryInfo struct {
	Epoch  int32
	Amount string
	PoolID string
}

AccountRewardHistoryInfo holds a stake-account reward history row.

type AccountRewardHistoryResponse added in v0.46.0

type AccountRewardHistoryResponse struct {
	Epoch  int32  `json:"epoch"`
	Amount string `json:"amount"`
	PoolID string `json:"pool_id"`
}

AccountRewardHistoryResponse represents a stake-account reward history row.

type AddressAmountInfo added in v0.33.0

type AddressAmountInfo struct {
	Unit     string
	Quantity string
}

AddressAmountInfo holds amount data needed by address UTxO responses.

type AddressAmountResponse added in v0.33.0

type AddressAmountResponse struct {
	Unit     string `json:"unit"`
	Quantity string `json:"quantity"`
}

AddressAmountResponse represents a Blockfrost address amount object.

type AddressTransactionInfo added in v0.33.0

type AddressTransactionInfo struct {
	TxHash      string
	TxIndex     uint32
	BlockHeight uint64
	BlockTime   int64
}

AddressTransactionInfo holds address transaction data needed by the API.

type AddressTransactionResponse added in v0.33.0

type AddressTransactionResponse struct {
	TxHash      string `json:"tx_hash"`
	TxIndex     int    `json:"tx_index"`
	BlockHeight uint64 `json:"block_height"`
	BlockTime   int    `json:"block_time"`
}

AddressTransactionResponse represents a Blockfrost address transaction object.

type AddressUTXOInfo added in v0.33.0

type AddressUTXOInfo struct {
	Address             string
	TxHash              string
	OutputIndex         uint32
	Amount              []AddressAmountInfo
	Block               string
	DataHash            *string
	InlineDatum         *string
	ReferenceScriptHash *string
}

AddressUTXOInfo holds address UTxO data needed by the API.

type AddressUTXOResponse added in v0.33.0

type AddressUTXOResponse struct {
	Address             string                  `json:"address"`
	TxHash              string                  `json:"tx_hash"`
	OutputIndex         int                     `json:"output_index"`
	Amount              []AddressAmountResponse `json:"amount"`
	Block               string                  `json:"block"`
	DataHash            *string                 `json:"data_hash"`
	InlineDatum         *string                 `json:"inline_datum"`
	ReferenceScriptHash *string                 `json:"reference_script_hash"`
}

AddressUTXOResponse represents a Blockfrost address UTxO object.

type AssetInfo added in v0.36.0

type AssetInfo struct {
	Asset             string
	PolicyID          string
	AssetName         string
	AssetNameASCII    string
	Fingerprint       string
	Quantity          string
	InitialMintTxHash string
	MintOrBurnCount   int
	OnchainMetadata   *any
}

AssetInfo holds native asset data needed by the API.

type AssetResponse added in v0.36.0

type AssetResponse struct {
	Asset                   string  `json:"asset"`
	PolicyID                string  `json:"policy_id"`
	AssetName               string  `json:"asset_name"`
	AssetNameASCII          string  `json:"asset_name_ascii"`
	Fingerprint             string  `json:"fingerprint"`
	Quantity                string  `json:"quantity"`
	InitialMintTxHash       string  `json:"initial_mint_tx_hash"`
	MintOrBurnCount         int     `json:"mint_or_burn_count"`
	OnchainMetadata         *any    `json:"onchain_metadata"`
	OnchainMetadataStandard *string `json:"onchain_metadata_standard"`
	OnchainMetadataExtra    *string `json:"onchain_metadata_extra"`
	Metadata                *any    `json:"metadata"`
}

AssetResponse represents a Blockfrost native asset object.

type BlockInfo

type BlockInfo struct {
	Hash          string
	Slot          uint64
	Epoch         uint64
	EpochSlot     uint64
	Height        uint64
	Time          int64
	Size          uint64
	TxCount       int
	SlotLeader    string
	PreviousBlock string
	Confirmations uint64
}

BlockInfo holds block data needed by the API.

type BlockResponse

type BlockResponse struct {
	Time          int64   `json:"time"`
	Height        uint64  `json:"height"`
	Hash          string  `json:"hash"`
	Slot          uint64  `json:"slot"`
	Epoch         uint64  `json:"epoch"`
	EpochSlot     uint64  `json:"epoch_slot"`
	SlotLeader    string  `json:"slot_leader"`
	Size          uint64  `json:"size"`
	TxCount       int     `json:"tx_count"`
	Output        *string `json:"output"`
	Fees          *string `json:"fees"`
	BlockVRF      *string `json:"block_vrf"`
	OPCert        *string `json:"op_cert"`
	OPCertCounter *string `json:"op_cert_counter"`
	PreviousBlock string  `json:"previous_block"`
	NextBlock     *string `json:"next_block"`
	Confirmations uint64  `json:"confirmations"`
}

BlockResponse represents a Blockfrost block object.

type Blockfrost

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

Blockfrost is the Blockfrost-compatible REST API server.

func New

func New(
	cfg BlockfrostConfig,
	node BlockfrostNode,
	logger *slog.Logger,
) *Blockfrost

New creates a new Blockfrost API server instance.

func (*Blockfrost) Start

func (b *Blockfrost) Start(
	ctx context.Context,
) error

Start starts the HTTP server in a background goroutine.

func (*Blockfrost) Stop

func (b *Blockfrost) Stop(
	ctx context.Context,
) error

Stop gracefully shuts down the HTTP server.

type BlockfrostConfig

type BlockfrostConfig struct {
	// ListenAddress is the address to listen on.
	// Defaults to ":3000".
	ListenAddress string
}

BlockfrostConfig holds configuration for the Blockfrost API server.

type BlockfrostNode

type BlockfrostNode interface {
	// ChainTip returns the current chain tip info.
	ChainTip() (ChainTipInfo, error)

	// LatestBlock returns information about the latest
	// block on the chain.
	LatestBlock() (BlockInfo, error)

	// BlockByHashOrNumber returns information about a block
	// identified by a 64-character hex hash or decimal height.
	BlockByHashOrNumber(id string) (BlockInfo, error)

	// LatestBlockTxHashes returns the transaction hashes
	// for the latest block.
	LatestBlockTxHashes() ([]string, error)

	// CurrentEpoch returns information about the current
	// epoch.
	CurrentEpoch() (EpochInfo, error)

	// CurrentProtocolParams returns the current protocol
	// parameters.
	CurrentProtocolParams() (ProtocolParamsInfo, error)

	// EpochProtocolParams returns protocol parameters for a
	// specific epoch.
	EpochProtocolParams(epoch uint64) (ProtocolParamsInfo, error)

	// Network returns current network supply and stake information.
	Network() (NetworkInfo, error)

	// NetworkEras returns hard-fork era summaries.
	NetworkEras() ([]NetworkEraInfo, error)

	// Genesis returns Shelley genesis configuration values.
	Genesis() (GenesisInfo, error)

	// PoolsExtended returns the current active pools with
	// extended details.
	PoolsExtended() ([]PoolExtendedInfo, error)

	// AddressUTXOs returns the paginated current UTxOs for
	// an address along with the total number of matching
	// results before pagination.
	AddressUTXOs(
		address string,
		params PaginationParams,
	) ([]AddressUTXOInfo, int, error)

	// AddressTransactions returns the paginated transaction
	// history for an address along with the total number of
	// matching results before pagination.
	AddressTransactions(
		address string,
		params PaginationParams,
	) ([]AddressTransactionInfo, int, error)

	// MetadataTransactions returns the paginated transactions
	// containing the requested metadata label, with JSON values.
	MetadataTransactions(
		label uint64,
		params PaginationParams,
	) ([]MetadataTransactionJSONInfo, int, error)

	// MetadataTransactionsCBOR returns the paginated transactions
	// containing the requested metadata label, with CBOR values.
	MetadataTransactionsCBOR(
		label uint64,
		params PaginationParams,
	) ([]MetadataTransactionCBORInfo, int, error)

	// Transaction returns summary details for a transaction hash.
	Transaction(hash []byte) (TransactionInfo, error)

	// TransactionSubmit submits raw signed transaction CBOR to the mempool.
	TransactionSubmit(txCbor []byte) (string, error)

	// TransactionCBOR returns raw signed transaction CBOR bytes.
	TransactionCBOR(hash []byte) ([]byte, error)

	// TransactionMetadata returns transaction metadata labels as JSON values.
	TransactionMetadata(hash []byte) ([]TransactionMetadataInfo, error)

	// TransactionMetadataCBOR returns transaction metadata labels as CBOR values.
	TransactionMetadataCBOR(hash []byte) ([]TransactionMetadataCBORInfo, error)

	// TransactionUTXOs returns transaction inputs and outputs.
	TransactionUTXOs(hash []byte) (TransactionUTXOsInfo, error)

	// TransactionDelegations returns delegation certificates in a transaction.
	TransactionDelegations(hash []byte) ([]TransactionDelegationInfo, error)

	// TransactionStakeAddresses returns stake address certificates in a transaction.
	TransactionStakeAddresses(hash []byte) ([]TransactionStakeAddressInfo, error)

	// TransactionWithdrawals returns reward withdrawals in a transaction.
	TransactionWithdrawals(hash []byte) ([]TransactionWithdrawalInfo, error)

	// TransactionMIRs returns MIR certificates in a transaction.
	TransactionMIRs(hash []byte) ([]TransactionMIRInfo, error)

	// TransactionPoolUpdates returns pool registration certificates in a transaction.
	TransactionPoolUpdates(hash []byte) ([]TransactionPoolUpdateInfo, error)

	// TransactionPoolRetires returns pool retirement certificates in a transaction.
	TransactionPoolRetires(hash []byte) ([]TransactionPoolRetireInfo, error)

	// TransactionRedeemers returns Plutus redeemers in a transaction.
	TransactionRedeemers(hash []byte) ([]TransactionRedeemerInfo, error)

	// TransactionRequiredSigners returns required signing key hashes in a transaction.
	TransactionRequiredSigners(hash []byte) ([]TransactionRequiredSignerInfo, error)

	// Asset returns native asset information for a
	// concatenated hex asset ID ({policy_id}{asset_name}).
	Asset(
		policyID string,
		assetName []byte,
	) (AssetInfo, error)

	// DRep returns governance DRep information for a parsed
	// DRep credential.
	DRep(DRepCredential) (DRepInfo, error)

	// Account returns stake-account information for the
	// requested stake address.
	Account(string) (AccountInfo, error)

	// AccountAssociatedAddresses returns payment addresses
	// associated with the requested stake address.
	AccountAssociatedAddresses(
		string,
		PaginationParams,
	) ([]AccountAssociatedAddressInfo, int, error)

	// AccountDelegationHistory returns delegation history
	// rows for the requested stake address.
	AccountDelegationHistory(
		string,
		PaginationParams,
	) ([]AccountDelegationHistoryInfo, int, error)

	// AccountRegistrationHistory returns registration
	// history rows for the requested stake address.
	AccountRegistrationHistory(
		string,
		PaginationParams,
	) ([]AccountRegistrationHistoryInfo, int, error)

	// AccountRewardHistory returns reward history rows for
	// the requested stake address.
	AccountRewardHistory(
		string,
		PaginationParams,
	) ([]AccountRewardHistoryInfo, int, error)
}

BlockfrostNode is the interface that the Blockfrost API server uses to query the node for blockchain data. This decouples the HTTP server from the concrete Node struct and enables testing with mock implementations.

type ChainTipInfo

type ChainTipInfo struct {
	BlockHash   string
	Slot        uint64
	BlockNumber uint64
}

ChainTipInfo holds chain tip data needed by the API.

type DRepCredential added in v0.40.0

type DRepCredential struct {
	ID        string
	Hash      []byte
	HasScript bool
}

DRepCredential holds a parsed governance DRep identifier.

type DRepInfo added in v0.40.0

type DRepInfo struct {
	DRepID      string
	Hex         string
	HasScript   bool
	Registered  bool
	Epoch       uint64
	Amount      string
	Active      bool
	ActiveEpoch uint64
	LiveStake   string
}

DRepInfo holds DRep data needed by the governance API.

type DRepResponse added in v0.40.0

type DRepResponse struct {
	DRepID      string `json:"drep_id"`
	Hex         string `json:"hex"`
	HasScript   bool   `json:"has_script"`
	Registered  bool   `json:"registered"`
	Epoch       uint64 `json:"epoch"`
	Amount      string `json:"amount"`
	Active      bool   `json:"active"`
	ActiveEpoch uint64 `json:"active_epoch"`
	LiveStake   string `json:"live_stake"`
}

DRepResponse represents a Blockfrost governance DRep object.

type EpochInfo

type EpochInfo struct {
	Epoch          uint64
	StartTime      int64
	EndTime        int64
	FirstBlockTime int64
	LastBlockTime  int64
	BlockCount     int
	TxCount        int
}

EpochInfo holds epoch data needed by the API.

type EpochResponse

type EpochResponse struct {
	Epoch          uint64  `json:"epoch"`
	StartTime      int64   `json:"start_time"`
	EndTime        int64   `json:"end_time"`
	FirstBlockTime int64   `json:"first_block_time"`
	LastBlockTime  int64   `json:"last_block_time"`
	BlockCount     int     `json:"block_count"`
	TxCount        int     `json:"tx_count"`
	Output         string  `json:"output"`
	Fees           string  `json:"fees"`
	ActiveStake    *string `json:"active_stake"`
}

EpochResponse represents a Blockfrost epoch object.

type ErrorResponse

type ErrorResponse struct {
	StatusCode int    `json:"status_code"`
	Error      string `json:"error"`
	Message    string `json:"message"`
}

ErrorResponse represents a Blockfrost error response.

type GenesisInfo added in v0.37.0

type GenesisInfo struct {
	ActiveSlotsCoefficient float32
	UpdateQuorum           int
	MaxLovelaceSupply      string
	NetworkMagic           int
	EpochLength            int
	SystemStart            int
	SlotsPerKESPeriod      int
	SlotLength             int
	MaxKESEvolutions       int
	SecurityParam          int
}

GenesisInfo holds Shelley genesis configuration values.

type GenesisResponse added in v0.37.0

type GenesisResponse struct {
	ActiveSlotsCoefficient float32 `json:"active_slots_coefficient"`
	UpdateQuorum           int     `json:"update_quorum"`
	MaxLovelaceSupply      string  `json:"max_lovelace_supply"`
	NetworkMagic           int     `json:"network_magic"`
	EpochLength            int     `json:"epoch_length"`
	SystemStart            int     `json:"system_start"`
	SlotsPerKESPeriod      int     `json:"slots_per_kes_period"`
	SlotLength             int     `json:"slot_length"`
	MaxKESEvolutions       int     `json:"max_kes_evolutions"`
	SecurityParam          int     `json:"security_param"`
}

GenesisResponse represents Blockfrost genesis info.

type HealthResponse

type HealthResponse struct {
	IsHealthy bool `json:"is_healthy"`
}

HealthResponse is returned by GET /health.

type MetadataTransactionCBORInfo added in v0.34.0

type MetadataTransactionCBORInfo struct {
	TxHash   string
	Metadata string
}

MetadataTransactionCBORInfo holds metadata label query data for the CBOR endpoint.

type MetadataTransactionCBORResponse added in v0.34.0

type MetadataTransactionCBORResponse struct {
	TxHash       string  `json:"tx_hash"`
	CborMetadata *string `json:"cbor_metadata"`
	Metadata     string  `json:"metadata"`
}

MetadataTransactionCBORResponse represents a Blockfrost metadata label transaction item with CBOR content.

type MetadataTransactionJSONInfo added in v0.34.0

type MetadataTransactionJSONInfo struct {
	TxHash       string
	JSONMetadata json.RawMessage
}

MetadataTransactionJSONInfo holds metadata label query data for the JSON endpoint.

type MetadataTransactionJSONResponse added in v0.34.0

type MetadataTransactionJSONResponse struct {
	TxHash       string          `json:"tx_hash"`
	JSONMetadata json.RawMessage `json:"json_metadata"`
}

MetadataTransactionJSONResponse represents a Blockfrost metadata label transaction item with JSON content.

type NetworkEraBound added in v0.37.0

type NetworkEraBound struct {
	Time  int64  `json:"time"`
	Slot  uint64 `json:"slot"`
	Epoch uint64 `json:"epoch"`
}

NetworkEraBound represents an era boundary.

type NetworkEraBoundInfo added in v0.37.0

type NetworkEraBoundInfo struct {
	Time  int64
	Slot  uint64
	Epoch uint64
}

NetworkEraBoundInfo holds an era boundary.

type NetworkEraInfo added in v0.37.0

type NetworkEraInfo struct {
	Era    string
	Start  NetworkEraBoundInfo
	End    *NetworkEraBoundInfo
	Params NetworkEraParamsInfo
}

NetworkEraInfo holds a Blockfrost hard-fork era summary.

type NetworkEraParameters added in v0.37.0

type NetworkEraParameters struct {
	EpochLength uint64 `json:"epoch_length"`
	SlotLength  uint64 `json:"slot_length"`
	SafeZone    uint64 `json:"safe_zone"`
}

NetworkEraParameters represents era timing parameters.

type NetworkEraParamsInfo added in v0.37.0

type NetworkEraParamsInfo struct {
	EpochLength uint64
	SlotLength  uint64
	SafeZone    uint64
}

NetworkEraParamsInfo holds era timing parameters.

type NetworkEraResponse added in v0.37.0

type NetworkEraResponse struct {
	Era        string               `json:"era,omitempty"`
	Start      NetworkEraBound      `json:"start"`
	End        *NetworkEraBound     `json:"end"`
	Parameters NetworkEraParameters `json:"parameters"`
}

NetworkEraResponse represents a Blockfrost era summary.

type NetworkInfo added in v0.37.0

type NetworkInfo struct {
	Supply NetworkSupplyInfo
	Stake  NetworkStakeInfo
}

NetworkInfo holds network supply and stake data needed by the API.

type NetworkResponse

type NetworkResponse struct {
	Supply NetworkSupply `json:"supply"`
	Stake  NetworkStake  `json:"stake"`
}

NetworkResponse represents Blockfrost network info.

type NetworkStake

type NetworkStake struct {
	Live   string `json:"live"`
	Active string `json:"active"`
}

NetworkStake holds stake information.

type NetworkStakeInfo added in v0.37.0

type NetworkStakeInfo struct {
	Live   string
	Active string
}

NetworkStakeInfo holds network stake data needed by the API.

type NetworkSupply

type NetworkSupply struct {
	Max         string `json:"max"`
	Total       string `json:"total"`
	Circulating string `json:"circulating"`
	Locked      string `json:"locked"`
	Treasury    string `json:"treasury"`
	Reserves    string `json:"reserves"`
}

NetworkSupply holds supply information.

type NetworkSupplyInfo added in v0.37.0

type NetworkSupplyInfo struct {
	Max         string
	Total       string
	Circulating string
	Locked      string
	Treasury    string
	Reserves    string
}

NetworkSupplyInfo holds network supply data needed by the API.

type NodeAdapter

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

NodeAdapter wraps a real dingo Node's LedgerState to implement the BlockfrostNode interface.

func NewNodeAdapter

func NewNodeAdapter(
	ls *ledger.LedgerState,
	submitter TransactionSubmitter,
) (*NodeAdapter, error)

NewNodeAdapter creates a NodeAdapter that queries the given LedgerState for blockchain data.

func (*NodeAdapter) Account added in v0.46.0

func (a *NodeAdapter) Account(
	stakeAddress string,
) (AccountInfo, error)

Account returns stake-account information for the requested stake address.

func (*NodeAdapter) AccountAssociatedAddresses added in v0.46.0

func (a *NodeAdapter) AccountAssociatedAddresses(
	stakeAddress string,
	params PaginationParams,
) ([]AccountAssociatedAddressInfo, int, error)

AccountAssociatedAddresses returns payment addresses associated with the requested stake address.

func (*NodeAdapter) AccountDelegationHistory added in v0.46.0

func (a *NodeAdapter) AccountDelegationHistory(
	stakeAddress string,
	params PaginationParams,
) ([]AccountDelegationHistoryInfo, int, error)

AccountDelegationHistory returns delegation history rows for the requested stake address.

func (*NodeAdapter) AccountRegistrationHistory added in v0.46.0

func (a *NodeAdapter) AccountRegistrationHistory(
	stakeAddress string,
	params PaginationParams,
) ([]AccountRegistrationHistoryInfo, int, error)

AccountRegistrationHistory returns registration history rows for the requested stake address.

func (*NodeAdapter) AccountRewardHistory added in v0.46.0

func (a *NodeAdapter) AccountRewardHistory(
	stakeAddress string,
	params PaginationParams,
) ([]AccountRewardHistoryInfo, int, error)

AccountRewardHistory returns reward history rows for the requested stake address.

func (*NodeAdapter) AddressTransactions added in v0.33.0

func (a *NodeAdapter) AddressTransactions(
	address string,
	params PaginationParams,
) ([]AddressTransactionInfo, int, error)

AddressTransactions returns paginated transaction history for the requested address.

func (*NodeAdapter) AddressUTXOs added in v0.33.0

func (a *NodeAdapter) AddressUTXOs(
	address string,
	params PaginationParams,
) ([]AddressUTXOInfo, int, error)

AddressUTXOs returns paginated current UTxOs for the requested address.

func (*NodeAdapter) Asset added in v0.36.0

func (a *NodeAdapter) Asset(
	policyID string,
	assetName []byte,
) (AssetInfo, error)

Asset returns native asset information for a policy ID and raw asset name bytes.

func (*NodeAdapter) BlockByHashOrNumber added in v0.37.0

func (a *NodeAdapter) BlockByHashOrNumber(
	id string,
) (BlockInfo, error)

BlockByHashOrNumber returns block information by hash or height.

func (*NodeAdapter) ChainTip

func (a *NodeAdapter) ChainTip() (
	ChainTipInfo, error,
)

ChainTip returns the current chain tip from the ledger state.

func (*NodeAdapter) CurrentEpoch

func (a *NodeAdapter) CurrentEpoch() (
	EpochInfo, error,
)

CurrentEpoch returns information about the current epoch.

func (*NodeAdapter) CurrentProtocolParams

func (a *NodeAdapter) CurrentProtocolParams() (
	ProtocolParamsInfo, error,
)

CurrentProtocolParams returns the current protocol parameters.

func (*NodeAdapter) DRep added in v0.40.0

func (a *NodeAdapter) DRep(
	credential DRepCredential,
) (DRepInfo, error)

DRep returns governance DRep information for the requested credential.

func (*NodeAdapter) EpochProtocolParams added in v0.33.0

func (a *NodeAdapter) EpochProtocolParams(
	epoch uint64,
) (ProtocolParamsInfo, error)

EpochProtocolParams returns protocol parameters for the requested epoch.

func (*NodeAdapter) Genesis added in v0.37.0

func (a *NodeAdapter) Genesis() (GenesisInfo, error)

Genesis returns Shelley genesis configuration values.

func (*NodeAdapter) LatestBlock

func (a *NodeAdapter) LatestBlock() (
	BlockInfo, error,
)

LatestBlock returns information about the latest block.

func (*NodeAdapter) LatestBlockTxHashes

func (a *NodeAdapter) LatestBlockTxHashes() (
	[]string, error,
)

LatestBlockTxHashes returns transaction hashes from the latest block.

func (*NodeAdapter) MetadataTransactions added in v0.34.0

func (a *NodeAdapter) MetadataTransactions(
	label uint64,
	params PaginationParams,
) ([]MetadataTransactionJSONInfo, int, error)

MetadataTransactions returns paginated transaction metadata values for the requested label in JSON form.

func (*NodeAdapter) MetadataTransactionsCBOR added in v0.34.0

func (a *NodeAdapter) MetadataTransactionsCBOR(
	label uint64,
	params PaginationParams,
) ([]MetadataTransactionCBORInfo, int, error)

MetadataTransactionsCBOR returns paginated transaction metadata values for the requested label in CBOR-hex form.

func (*NodeAdapter) Network added in v0.37.0

func (a *NodeAdapter) Network() (NetworkInfo, error)

Network returns current network supply and stake information.

func (*NodeAdapter) NetworkEras added in v0.37.0

func (a *NodeAdapter) NetworkEras() ([]NetworkEraInfo, error)

NetworkEras returns hard-fork era summaries.

func (*NodeAdapter) PoolsExtended added in v0.30.0

func (a *NodeAdapter) PoolsExtended() (
	[]PoolExtendedInfo, error,
)

PoolsExtended returns the current active pools with extended details.

func (*NodeAdapter) Transaction added in v0.44.0

func (a *NodeAdapter) Transaction(
	hash []byte,
) (TransactionInfo, error)

Transaction returns summary details for the requested transaction.

func (*NodeAdapter) TransactionCBOR added in v0.44.0

func (a *NodeAdapter) TransactionCBOR(
	hash []byte,
) ([]byte, error)

TransactionCBOR returns raw signed transaction CBOR bytes for the requested transaction hash.

func (*NodeAdapter) TransactionDelegations added in v0.44.0

func (a *NodeAdapter) TransactionDelegations(
	hash []byte,
) ([]TransactionDelegationInfo, error)

TransactionDelegations returns delegation certificates in the requested transaction.

func (*NodeAdapter) TransactionMIRs added in v0.44.0

func (a *NodeAdapter) TransactionMIRs(
	hash []byte,
) ([]TransactionMIRInfo, error)

TransactionMIRs returns MIR certificate reward targets in the requested transaction.

func (*NodeAdapter) TransactionMetadata added in v0.44.0

func (a *NodeAdapter) TransactionMetadata(
	hash []byte,
) ([]TransactionMetadataInfo, error)

TransactionMetadata returns metadata labels for the requested transaction as JSON values.

func (*NodeAdapter) TransactionMetadataCBOR added in v0.44.0

func (a *NodeAdapter) TransactionMetadataCBOR(
	hash []byte,
) ([]TransactionMetadataCBORInfo, error)

TransactionMetadataCBOR returns metadata labels for the requested transaction as CBOR hex values.

func (*NodeAdapter) TransactionPoolRetires added in v0.44.0

func (a *NodeAdapter) TransactionPoolRetires(
	hash []byte,
) ([]TransactionPoolRetireInfo, error)

TransactionPoolRetires returns pool retirement certificates in the requested transaction.

func (*NodeAdapter) TransactionPoolUpdates added in v0.44.0

func (a *NodeAdapter) TransactionPoolUpdates(
	hash []byte,
) ([]TransactionPoolUpdateInfo, error)

TransactionPoolUpdates returns pool registration certificates in the requested transaction.

func (*NodeAdapter) TransactionRedeemers added in v0.44.0

func (a *NodeAdapter) TransactionRedeemers(
	hash []byte,
) ([]TransactionRedeemerInfo, error)

TransactionRedeemers returns Plutus redeemers stored for the requested transaction.

func (*NodeAdapter) TransactionRequiredSigners added in v0.44.0

func (a *NodeAdapter) TransactionRequiredSigners(
	hash []byte,
) ([]TransactionRequiredSignerInfo, error)

TransactionRequiredSigners returns the required signers (extra signing key hashes) declared in the requested transaction.

func (*NodeAdapter) TransactionStakeAddresses added in v0.44.0

func (a *NodeAdapter) TransactionStakeAddresses(
	hash []byte,
) ([]TransactionStakeAddressInfo, error)

TransactionStakeAddresses returns stake registration/deregistration certificates in the requested transaction.

func (*NodeAdapter) TransactionSubmit added in v0.44.0

func (a *NodeAdapter) TransactionSubmit(
	txCbor []byte,
) (string, error)

TransactionSubmit submits raw signed transaction CBOR to the mempool.

func (*NodeAdapter) TransactionUTXOs added in v0.44.0

func (a *NodeAdapter) TransactionUTXOs(
	hash []byte,
) (TransactionUTXOsInfo, error)

TransactionUTXOs returns inputs and outputs for the requested transaction.

func (*NodeAdapter) TransactionWithdrawals added in v0.44.0

func (a *NodeAdapter) TransactionWithdrawals(
	hash []byte,
) ([]TransactionWithdrawalInfo, error)

TransactionWithdrawals returns reward withdrawals in the requested transaction.

type PaginationParams

type PaginationParams struct {
	Count int
	Page  int
	Order string
}

PaginationParams contains parsed pagination query values.

func ParsePagination

func ParsePagination(r *http.Request) (PaginationParams, error)

ParsePagination parses pagination query parameters and applies defaults and bounds clamping.

type PoolExtendedInfo added in v0.30.0

type PoolExtendedInfo struct {
	PoolID         string
	Hex            string
	VrfKey         string
	ActiveStake    string
	LiveStake      string
	DeclaredPledge string
	FixedCost      string
	MarginCost     float64
	Relays         []PoolRelayInfo
}

PoolExtendedInfo holds pool data needed by the /pools/extended endpoint.

type PoolExtendedResponse added in v0.30.0

type PoolExtendedResponse struct {
	PoolID         string              `json:"pool_id"`
	Hex            string              `json:"hex"`
	VrfKey         string              `json:"vrf_key"`
	ActiveStake    string              `json:"active_stake"`
	LiveStake      string              `json:"live_stake"`
	DeclaredPledge string              `json:"declared_pledge"`
	FixedCost      string              `json:"fixed_cost"`
	MarginCost     float64             `json:"margin_cost"`
	Relays         []PoolRelayResponse `json:"relays"`
}

PoolExtendedResponse represents an extended stake pool list item.

type PoolRelayInfo added in v0.30.0

type PoolRelayInfo struct {
	IPv4 string
	IPv6 string
	DNS  string
	Port *int
}

PoolRelayInfo holds relay data for pool responses.

type PoolRelayResponse added in v0.30.0

type PoolRelayResponse struct {
	IPv4 *string `json:"ipv4"`
	IPv6 *string `json:"ipv6"`
	DNS  *string `json:"dns"`
	Port *int    `json:"port"`
}

PoolRelayResponse represents a stake pool relay.

type ProtocolParamsInfo

type ProtocolParamsInfo struct {
	Epoch               uint64
	MinFeeA             int
	MinFeeB             int
	MaxBlockSize        int
	MaxTxSize           int
	MaxBlockHeaderSize  int
	KeyDeposit          string
	PoolDeposit         string
	EMax                int
	NOpt                int
	A0                  float64
	Rho                 float64
	Tau                 float64
	ProtocolMajorVer    int
	ProtocolMinorVer    int
	MinPoolCost         string
	CoinsPerUtxoSize    string
	PriceMem            float64
	PriceStep           float64
	MaxTxExMem          string
	MaxTxExSteps        string
	MaxBlockExMem       string
	MaxBlockExSteps     string
	MaxValSize          string
	CollateralPercent   int
	MaxCollateralInputs int
}

ProtocolParamsInfo holds protocol parameter data needed by the API.

type ProtocolParamsResponse

type ProtocolParamsResponse struct {
	Epoch              uint64  `json:"epoch"`
	MinFeeA            int     `json:"min_fee_a"`
	MinFeeB            int     `json:"min_fee_b"`
	MaxBlockSize       int     `json:"max_block_size"`
	MaxTxSize          int     `json:"max_tx_size"`
	MaxBlockHeaderSize int     `json:"max_block_header_size"`
	KeyDeposit         string  `json:"key_deposit"`
	PoolDeposit        string  `json:"pool_deposit"`
	EMax               int     `json:"e_max"`
	NOpt               int     `json:"n_opt"`
	A0                 float64 `json:"a0"`
	Rho                float64 `json:"rho"`
	Tau                float64 `json:"tau"`
	//nolint:tagliatelle
	DecentralisationParam float64         `json:"decentralisation_param"`
	ExtraEntropy          *map[string]any `json:"extra_entropy"`
	ProtocolMajorVer      int             `json:"protocol_major_ver"`
	ProtocolMinorVer      int             `json:"protocol_minor_ver"`
	MinUtxo               string          `json:"min_utxo"`
	MinPoolCost           string          `json:"min_pool_cost"`
	Nonce                 string          `json:"nonce"`
	CoinsPerUtxoSize      *string         `json:"coins_per_utxo_size"`
	CoinsPerUtxoWord      string          `json:"coins_per_utxo_word"`
	CostModels            *any            `json:"cost_models"`
	PriceMem              *float64        `json:"price_mem"`
	PriceStep             *float64        `json:"price_step"`
	MaxTxExMem            *string         `json:"max_tx_ex_mem"`
	MaxTxExSteps          *string         `json:"max_tx_ex_steps"`
	MaxBlockExMem         *string         `json:"max_block_ex_mem"`
	MaxBlockExSteps       *string         `json:"max_block_ex_steps"`
	MaxValSize            *string         `json:"max_val_size"`
	CollateralPercent     *int            `json:"collateral_percent"`
	MaxCollateralInputs   *int            `json:"max_collateral_inputs"`
}

ProtocolParamsResponse represents Blockfrost protocol parameters.

type RootResponse

type RootResponse struct {
	URL     string `json:"url"`
	Version string `json:"version"`
}

RootResponse is returned by GET /.

type TransactionCBORResponse added in v0.44.0

type TransactionCBORResponse struct {
	CBOR string `json:"cbor"`
}

TransactionCBORResponse represents transaction CBOR in hex form.

type TransactionDelegationInfo added in v0.44.0

type TransactionDelegationInfo struct {
	Address     string
	PoolID      string
	CertIndex   int
	ActiveEpoch uint64
}

TransactionDelegationInfo holds one delegation certificate.

type TransactionDelegationResponse added in v0.44.0

type TransactionDelegationResponse struct {
	Address     string `json:"address"`
	PoolID      string `json:"pool_id"`
	CertIndex   int    `json:"cert_index"`
	ActiveEpoch uint64 `json:"active_epoch"`
}

TransactionDelegationResponse represents one delegation certificate.

type TransactionInfo added in v0.44.0

type TransactionInfo struct {
	InvalidBefore      *string
	InvalidHereafter   *string
	OutputAmount       []AddressAmountInfo
	Hash               string
	Block              string
	Deposit            string
	Fees               string
	Slot               uint64
	BlockHeight        uint64
	BlockTime          int64
	Size               int
	Index              uint32
	UtxoCount          int
	WithdrawalCount    int
	MirCertCount       int
	DelegationCount    int
	StakeCertCount     int
	PoolUpdateCount    int
	PoolRetireCount    int
	AssetMintBurnCount int
	RedeemerCount      int
	ValidContract      bool
}

TransactionInfo holds transaction summary data needed by the API.

type TransactionInputInfo added in v0.44.0

type TransactionInputInfo struct {
	ReferenceScriptHash *string
	InlineDatum         *string
	DataHash            *string
	Address             string
	TxHash              string
	Amount              []AddressAmountInfo
	OutputIndex         uint32
	Collateral          bool
	Reference           *bool
}

TransactionInputInfo holds one transaction input.

type TransactionInputResponse added in v0.44.0

type TransactionInputResponse struct {
	ReferenceScriptHash *string                 `json:"reference_script_hash"`
	InlineDatum         *string                 `json:"inline_datum"`
	DataHash            *string                 `json:"data_hash"`
	Reference           *bool                   `json:"reference"`
	Address             string                  `json:"address"`
	TxHash              string                  `json:"tx_hash"`
	Amount              []AddressAmountResponse `json:"amount"`
	OutputIndex         int                     `json:"output_index"`
	Collateral          bool                    `json:"collateral"`
}

TransactionInputResponse represents one transaction input.

type TransactionMIRInfo added in v0.44.0

type TransactionMIRInfo struct {
	Address   string
	Amount    string
	CertIndex int
	Pot       string
}

TransactionMIRInfo holds one MIR target.

type TransactionMIRResponse added in v0.44.0

type TransactionMIRResponse struct {
	Address   string `json:"address"`
	Amount    string `json:"amount"`
	CertIndex int    `json:"cert_index"`
	Pot       string `json:"pot"`
}

TransactionMIRResponse represents one MIR certificate target.

type TransactionMetadataCBORInfo added in v0.44.0

type TransactionMetadataCBORInfo struct {
	CBORMetadata string
	Label        string
}

TransactionMetadataCBORInfo holds a transaction metadata label and CBOR value.

type TransactionMetadataCBORResponse added in v0.44.0

type TransactionMetadataCBORResponse struct {
	CborMetadata *string `json:"cbor_metadata"`
	Metadata     string  `json:"metadata"`
	Label        string  `json:"label"`
}

TransactionMetadataCBORResponse represents one transaction metadata label in CBOR form.

type TransactionMetadataInfo added in v0.44.0

type TransactionMetadataInfo struct {
	JSONMetadata json.RawMessage
	Label        string
}

TransactionMetadataInfo holds a transaction metadata label and JSON value.

type TransactionMetadataResponse added in v0.44.0

type TransactionMetadataResponse struct {
	JSONMetadata json.RawMessage `json:"json_metadata"`
	Label        string          `json:"label"`
}

TransactionMetadataResponse represents one transaction metadata label in JSON form.

type TransactionOutputInfo added in v0.44.0

type TransactionOutputInfo struct {
	ReferenceScriptHash *string
	InlineDatum         *string
	DataHash            *string
	ConsumedByTx        *string
	Address             string
	Amount              []AddressAmountInfo
	OutputIndex         uint32
	Collateral          bool
}

TransactionOutputInfo holds one transaction output.

type TransactionOutputResponse added in v0.44.0

type TransactionOutputResponse struct {
	ReferenceScriptHash *string                 `json:"reference_script_hash"`
	InlineDatum         *string                 `json:"inline_datum"`
	DataHash            *string                 `json:"data_hash"`
	ConsumedByTx        *string                 `json:"consumed_by_tx"`
	Address             string                  `json:"address"`
	Amount              []AddressAmountResponse `json:"amount"`
	OutputIndex         int                     `json:"output_index"`
	Collateral          bool                    `json:"collateral"`
}

TransactionOutputResponse represents one transaction output.

type TransactionPoolMetadataInfo added in v0.44.0

type TransactionPoolMetadataInfo struct {
	URL  string
	Hash string
}

TransactionPoolMetadataInfo holds on-chain pool metadata pointer data.

type TransactionPoolMetadataResponse added in v0.44.0

type TransactionPoolMetadataResponse struct {
	Hash string `json:"hash"`
	URL  string `json:"url"`
}

TransactionPoolMetadataResponse represents pool metadata pointer data.

type TransactionPoolRelayInfo added in v0.44.0

type TransactionPoolRelayInfo struct {
	DNS    string
	DNSSrv string
	IPv4   string
	IPv6   string
	Port   *int
}

TransactionPoolRelayInfo holds one pool relay from a pool registration cert.

type TransactionPoolRelayResponse added in v0.44.0

type TransactionPoolRelayResponse struct {
	DNS    *string `json:"dns"`
	DNSSrv *string `json:"dns_srv"`
	IPv4   *string `json:"ipv4"`
	IPv6   *string `json:"ipv6"`
	Port   *int    `json:"port"`
}

TransactionPoolRelayResponse represents one relay in a pool registration cert.

type TransactionPoolRetireInfo added in v0.44.0

type TransactionPoolRetireInfo struct {
	PoolID        string
	CertIndex     int
	RetiringEpoch uint64
}

TransactionPoolRetireInfo holds one pool retirement certificate.

type TransactionPoolRetireResponse added in v0.44.0

type TransactionPoolRetireResponse struct {
	PoolID        string `json:"pool_id"`
	CertIndex     int    `json:"cert_index"`
	RetiringEpoch uint64 `json:"retiring_epoch"`
}

TransactionPoolRetireResponse represents one pool retirement certificate.

type TransactionPoolUpdateInfo added in v0.44.0

type TransactionPoolUpdateInfo struct {
	Metadata      *TransactionPoolMetadataInfo
	Owners        []string
	Relays        []TransactionPoolRelayInfo
	ActiveEpoch   uint64
	CertIndex     int
	FixedCost     string
	MarginCost    float64
	Pledge        string
	PoolID        string
	RewardAccount string
	VrfKey        string
}

TransactionPoolUpdateInfo holds one pool registration certificate.

type TransactionPoolUpdateResponse added in v0.44.0

type TransactionPoolUpdateResponse struct {
	Metadata      *TransactionPoolMetadataResponse `json:"metadata"`
	Owners        []string                         `json:"owners"`
	Relays        []TransactionPoolRelayResponse   `json:"relays"`
	ActiveEpoch   uint64                           `json:"active_epoch"`
	CertIndex     int                              `json:"cert_index"`
	FixedCost     string                           `json:"fixed_cost"`
	MarginCost    float64                          `json:"margin_cost"`
	Pledge        string                           `json:"pledge"`
	PoolID        string                           `json:"pool_id"`
	RewardAccount string                           `json:"reward_account"`
	VrfKey        string                           `json:"vrf_key"`
}

TransactionPoolUpdateResponse represents one pool registration certificate.

type TransactionRedeemerInfo added in v0.44.0

type TransactionRedeemerInfo struct {
	TxIndex          int
	Purpose          string
	ScriptHash       string
	RedeemerDataHash string
	UnitMem          string
	UnitSteps        string
	Fee              string
}

TransactionRedeemerInfo holds one Plutus redeemer.

type TransactionRedeemerResponse added in v0.44.0

type TransactionRedeemerResponse struct {
	TxIndex          int    `json:"tx_index"`
	Purpose          string `json:"purpose"`
	ScriptHash       string `json:"script_hash"`
	RedeemerDataHash string `json:"redeemer_data_hash"`
	UnitMem          string `json:"unit_mem"`
	UnitSteps        string `json:"unit_steps"`
	Fee              string `json:"fee"`
}

TransactionRedeemerResponse represents one Plutus redeemer.

type TransactionRequiredSignerInfo added in v0.44.0

type TransactionRequiredSignerInfo struct {
	WitnessHash string
}

TransactionRequiredSignerInfo holds one required signing key hash.

type TransactionRequiredSignerResponse added in v0.44.0

type TransactionRequiredSignerResponse struct {
	WitnessHash string `json:"witness_hash"`
}

TransactionRequiredSignerResponse represents one required signing key hash.

type TransactionResponse added in v0.44.0

type TransactionResponse struct {
	InvalidBefore      *string                 `json:"invalid_before"`
	InvalidHereafter   *string                 `json:"invalid_hereafter"`
	OutputAmount       []AddressAmountResponse `json:"output_amount"`
	Hash               string                  `json:"hash"`
	Block              string                  `json:"block"`
	Deposit            string                  `json:"deposit"`
	Fees               string                  `json:"fees"`
	Slot               uint64                  `json:"slot"`
	BlockHeight        uint64                  `json:"block_height"`
	BlockTime          int64                   `json:"block_time"`
	Size               int                     `json:"size"`
	Index              int                     `json:"index"`
	UtxoCount          int                     `json:"utxo_count"`
	WithdrawalCount    int                     `json:"withdrawal_count"`
	MirCertCount       int                     `json:"mir_cert_count"`
	DelegationCount    int                     `json:"delegation_count"`
	StakeCertCount     int                     `json:"stake_cert_count"`
	PoolUpdateCount    int                     `json:"pool_update_count"`
	PoolRetireCount    int                     `json:"pool_retire_count"`
	AssetMintBurnCount int                     `json:"asset_mint_or_burn_count"`
	RedeemerCount      int                     `json:"redeemer_count"`
	ValidContract      bool                    `json:"valid_contract"`
}

TransactionResponse represents a Blockfrost transaction content object.

type TransactionStakeAddressInfo added in v0.44.0

type TransactionStakeAddressInfo struct {
	Address      string
	CertIndex    int
	Registration bool
}

TransactionStakeAddressInfo holds one stake registration/deregistration certificate.

type TransactionStakeAddressResponse added in v0.44.0

type TransactionStakeAddressResponse struct {
	Address      string `json:"address"`
	CertIndex    int    `json:"cert_index"`
	Registration bool   `json:"registration"`
}

TransactionStakeAddressResponse represents one stake address certificate.

type TransactionSubmitter added in v0.44.0

type TransactionSubmitter interface {
	AddTransaction(txType uint, txBytes []byte) error
}

TransactionSubmitter accepts raw transaction CBOR for mempool admission.

type TransactionUTXOsInfo added in v0.44.0

type TransactionUTXOsInfo struct {
	Hash    string
	Inputs  []TransactionInputInfo
	Outputs []TransactionOutputInfo
}

TransactionUTXOsInfo holds transaction inputs and outputs.

type TransactionUTXOsResponse added in v0.44.0

type TransactionUTXOsResponse struct {
	Hash    string                      `json:"hash"`
	Inputs  []TransactionInputResponse  `json:"inputs"`
	Outputs []TransactionOutputResponse `json:"outputs"`
}

TransactionUTXOsResponse represents transaction inputs and outputs.

type TransactionWithdrawalInfo added in v0.44.0

type TransactionWithdrawalInfo struct {
	Address string
	Amount  string
}

TransactionWithdrawalInfo holds one reward withdrawal.

type TransactionWithdrawalResponse added in v0.44.0

type TransactionWithdrawalResponse struct {
	Address string `json:"address"`
	Amount  string `json:"amount"`
}

TransactionWithdrawalResponse represents one reward withdrawal.

Jump to

Keyboard shortcuts

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