koios

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

README

Koios API Client Library for Go

⚠ UNTIL v1.0.0 RELEASE THIS LIBRARY WILL GET BREAKING CHANGES ⚠

  • before v1 every v0.x.x MINOR semver update most likely has breaking change.
  • before updating e.g. go get -u check for changes to prevent inconveniences.
  • v1.0.0 enhancements are tracked under following issue

Koios API is Elastic Cardano Query Layer!

A consistent query layer for developers to build upon Cardano, with
multiple, redundant endpoints that allow for easy scalability.

Koios API Client Library for Go

PkgGoDev

go get github.com/howijd/koios-rest-go-client
...
import (
  "github.com/howijd/koios-rest-go-client" // imports as package "koios"
)
...

CLI Application to interact with Koios API from Command-line see

See installing instruction

Build Status

linux macos windows

Development Status

GitHub last commit coverage codeql misspell Go Report Card



Usage

See Godoc PkgGoDev Additionally you can find all usecases by looking source of koio-rest Command-line application source which utilizes entire API of this library.

NOTE

Library normalizes some of the API responses and constructs Typed response for each end point. If you wish to work with *http.Response directly you can do so by using api client GET,POST, HEAD methods.

Basic usage

package main

import (
	"context"
	"fmt"
	"log"

	koios "github.com/howijd/koios-rest-go-client"
)

func main() {
  // Call to koios.New without options is same as calling it with default opts.
  // See godoc for available configuration options.
  // api, err := koios.New(
  // 	koios.Host(koios.MainnetHost),
  // 	koios.APIVersion(koios.DefaultAPIVersion),
  // 	koios.Port(koios.DefaultPort),
  // 	koios.Schema(koios.DefaultSchema),
  // 	koios.HttpClient(koios.DefaultHttpClient),
  // ).
  api, err := koios.New()
  if err != nil {
    log.Fatal(err)
  }

  res, err := api.GetTip(context.Background())
  if err != nil {
	  log.Fatal(err)
  }
  fmt.Println("status: ", res.Status)
  fmt.Println("statu_code: ", res.StatusCode)

  fmt.Println("abs_slot: ", res.Data.AbsSlot)
  fmt.Println("block_no: ", res.Data.BlockNo)
  fmt.Println("block_time: ", res.Data.BlockTime)
  fmt.Println("epoch: ", res.Data.Epoch)
  fmt.Println("epoch_slot: ", res.Data.EpochSlot)
  fmt.Println("hash: ", res.Data.Hash)
}

Concurrency using goroutines

This library is thread-safe so you can freerly use same api client instance passing it to your goroutines.

Following example uses goroutines to query chain tip from different endpoints.

func main() {
  api, _ := koios.New(
    // limit client request 1 per second even though
    // this example will send requests in goroutines.
    koios.RateLimit(1),
  )
  ctx := context.Background()
  var wg sync.WaitGroup
  servers := []string{
    "api.koios.rest",
    "guild.koios.rest",
    "testnet.koios.rest",
  }

  // Thanks to rate limit option requests will be made
  // once in a second.
  for _, host := range servers {
    wg.Add(1)
    go func(ctx context.Context, host string) {
      defer wg.Done()
      // switching host. all options changes are safe to call from goroutines.
      koios.Host(host)(api)
      res, _ := api.GET(ctx, "/tip", nil, nil)
      defer res.Body.Close()
      body, _ := ioutil.ReadAll(res.Body)
      fmt.Println("Host: ", host)
      fmt.Println("Response: ", string(body))
    }(ctx, host)
  }

  wg.Wait()
  fmt.Println("requests done: ", api.TotalRequests())
}

Lovelace (math on ada, assets and tokens).

Library uses for most cases to represent lovelace using Lovelace data type.

This library uses forked snapshot of github.com/shopspring/decimal package to provide
JSON and XML serialization/deserialization and make it ease to work with calculations
and deciimal precisions of ADA lovelace and native assets.

For decimal package API see

FORK: https://github.com/howijd/decimal
issues and bug reports are welcome to: https://github.com/howijd/decimal/issue. So that we can ensure that github.com/shopspring/decimal repository is not polluted with issues which are not problems with upstream library.

Implemented Endpoints

endpoint Go API CLI command API Doc
NETWORK
/tip *.GetTip(...) *TipResponse tip
/genesis *.GetGenesis(...) *GenesisResponse genesis
/totals *.GetTotals(...) *TotalsResponse totals
EPOCH
/epoch_info *.GetEpochInfo(...) *EpochInfoResponse epoch-info
/epoch_params *.GetEpochParams(...) *EpochParamsResponse epoch-params
BLOCK
/blocks *.GetBlocks(...) *BlocksResponse blocks
/block_info *.GetBlockInfo(...) *BlockInfoResponse block-info
/block_txs *.GetBlockTxs(...) *BlockTxsResponse block-txs
TRANSACTIONS
/tx_info *.GetTxsInfos(...) *TxsInfoResponse txs-infos
*.GetTxInfo(...) *TxInfoResponse tx-info
/tx_utxos *.GetTxsUTxOs(...) *TxUTxOsResponse tx-utxos
/tx_metadata *.GetTxsMetadata(...) *TxsMetadataResponse txs-metadata
*.GetTxMetadata(...) *TxMetadataResponse tx-metadata
/tx_metalabels *.GetTxMetaLabels(...) *TxMetaLabelsResponse tx-metalabels
/submittx *.SubmitSignedTx(...) *SubmitSignedTxResponse tx-submit
/tx_status *.GetTxsStatuses(...) *TxsStatusesResponse txs-statuses
*.GetTxStatus(...) *TxStatusResponse tx-status
ADDRESS
/address_info *.GetAddressInfo(...) *AddressInfoResponse address-info
/address_txs *.GetAddressTxs(...) *AddressTxsResponse address-txs
/address_assets *.GetAddressAssets(...) *AddressAssetsResponse address-assets
/credential_txs *.GetCredentialTxs(...) *CredentialTxsResponse credential-txs
ACCOUNT
/account_list *.GetAccountList(...) *AccountListResponse account-list
/account_info *.GetAccountInfo(...) *AccountListResponse account-info
/account_rewards *.GetAccountRewards(...) *AccountRewardsResponse account-rewards
/account_updates *.GetAccountUpdates(...) *AccountUpdatesResponse account-updates
/account_addresses *.GetAccountAddresses(...) *AccountAddressesResponse account-addresses
/account_assets *.GetAccountAssets(...) *AccountAssetsResponse account-assets
/account_history *.GetAccountHistory(...) *AccountHistoryResponse account-history
ASSET
/asset_list *.GetAssetList(...) *AssetAddressListResponse asset-list
/asset_address_list *.GetAssetAddressList(...) *AssetAddressListResponse asset-address-list
/asset_info *.GetAssetInfo(...) *AssetInfoResponse asset-info
/asset_summary *.GetAssetSummary(...) *AssetSummaryResponse asset-summary
/asset_txs *.GetAssetTxs(...) *AssetTxsResponse asset-txs
POOL
/pool_list *.GetPoolList(...) *PoolListResponse pool-list
/pool_info *.GetPoolInfos(...) *PoolInfoResponse pool-infos
*.GetPoolInfo(...) *PoolInfoResponse pool-info
/pool_delegators *.GetPoolDelegators(...) *PoolDelegatorsResponse pool-delegators
/pool_blocks *.GetPoolBlocks(...) *PoolBlocksResponse pool-blocks
/pool_updates *.GetPoolUpdates(...) *PoolUpdatesResponse pool-updates
/pool_relays *.GetPoolRelays(...) *PoolRelaysResponse pool-relays
/pool_metadata *.GetPoolMetadata(...) *PoolMetadataResponse pool-metadata
SCRIPT
/script_list *.GetScriptList(...) *ScriptRedeemersResponse script-list
/script_redeemers *.GetScriptRedeemers(...) *ScriptListResponse script-redeemers

CLI Application

source of cli: ./cmd/koios-rest.

Installation instructions

List of all commands

koios-rest --help
NAME:
   koios-rest - CLI Client to consume Koios API https://api.koios.rest

USAGE:
   koios-rest [global options] command [command options] [arguments...]

VERSION:
   (devel)

AUTHOR:
   The Howijd.Network Authors

COMMANDS:
   help, h  Shows a list of commands or help for one command
   ACCOUNT:
     account-list       Get a list of all accounts returns array of stake addresses.
     account-info       Get the account info of any (payment or staking) address.
     account-rewards    Get the full rewards history (including MIR) for a stake address, or certain epoch if specified.
     account-updates    Get the account updates (registration, deregistration, delegation and withdrawals).
     account-addresses  Get all addresses associated with an account payment or staking address
     account-assets     Get the native asset balance of an account.
     account-history    Get the staking history of an account.
   ADDRESS:
     address-info    Get address info - balance, associated stake address (if any) and UTxO set.
     address-txs     Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive).
     address-assets  Get the list of all the assets (policy, name and quantity) for a given address.
     credential-txs  Get the transaction hash list of input payment credential array, optionally filtering after specified block height (inclusive).
   ASSET:
     asset-list          Get the list of all native assets (paginated).
     asset-address-list  Get the list of all addresses holding a given asset.
     asset-info          Get the information of an asset including first minting & token registry metadata.
     asset-summary       Get the summary of an asset (total transactions exclude minting/total wallets include only wallets with asset balance).
     asset-txs           Get the list of all asset transaction hashes (newest first).
   BLOCK:
     blocks      Get summarised details about all blocks (paginated - latest first).
     block-info  Get detailed information about a specific block.
     block-txs   Get a list of all transactions included in a provided block.
   EPOCH:
     epoch-info    Get the epoch information, all epochs if no epoch specified.
     epoch-params  Get the protocol parameters for specific epoch, returns information about all epochs if no epoch specified.
   NETWORK:
     tip      Get the tip info about the latest block seen by chain.
     genesis  Get the Genesis parameters used to start specific era on chain.
     totals   Get the circulating utxo, treasury, rewards, supply and reserves in lovelace for specified epoch, all epochs if empty.
   POOL:
     pool-list        A list of all currently registered/retiring (not retired) pools.
     pool-infos       Current pool statuses and details for a specified list of pool ids.
     pool-info        Current pool status and details for a specified pool by pool id.
     pool-delegators  Return information about delegators by a given pool and optional epoch (current if omitted).
     pool-blocks      Return information about blocks minted by a given pool in current epoch (or _epoch_no if provided).
     pool-updates     Return all pool updates for all pools or only updates for specific pool if specified.
     pool-relays      A list of registered relays for all currently registered/retiring (not retired) pools.
     pool-metadata    Metadata(on & off-chain) for all currently registered/retiring (not retired) pools.
   SCRIPT:
     script-list       List of all existing script hashes along with their creation transaction hashes.
     script-redeemers  List of all redeemers for a given script hash.
   TRANSACTIONS:
     txs-infos      Get detailed information about transaction(s).
     tx-info        Get detailed information about single transaction.
     tx-utxos       Get UTxO set (inputs/outputs) of transactions.
     txs-metadata   Get metadata information (if any) for given transaction(s).
     tx-metadata    Get metadata information (if any) for given transaction.
     tx-metalabels  Get a list of all transaction metalabels.
     tx-submit      Submit signed transaction to the network.
     txs-statuses   Get the number of block confirmations for a given transaction hash list
     tx-status      Get the number of block confirmations for a given transaction hash
   UTILS:
     get   get issues a GET request to the specified API endpoint
     head  head issues a HEAD request to the specified API endpoint

GLOBAL OPTIONS:
   --port value, -p value  Set port (default: 443)
   --host value            Set host (default: "api.koios.rest")
   --api-version value     Set API version (default: "v0")
   --schema value          Set URL schema (default: "https")
   --origin value          Set Origin header for requests. (default: "https://github.com/howijd/koios-rest-go-client")
   --rate-limit value      Set API Client rate limit for outgoing requests (default: 5)
   --no-format             prints response json strings directly without calling json pretty. (default: false)
   --enable-req-stats      Enable request stats. (default: false)
   --testnet               use default testnet as host. (default: false)
   --help, -h              show help (default: false)
   --version, -v           print the version (default: false)

COPYRIGHT:
   (c) 2022

Example Usage

Example to query mainnet tip from cli
koios-rest --enable-req-stats tip

response

{
  "request_url": "https://api.koios.rest/api/v0/tip",
  "request_method": "GET",
  "status_code": 200,
  "status": "200 OK",
  "date": "Mon, 07 Feb 2022 12:49:49 GMT",
  "content_range": "0-0/*",
  "stats": {
    "req_started_at": "2022-02-07T12:49:48.565834833Z",
    "req_dns_lookup_dur": 1284269, // dns lookup duration in nanosecons.
    "tls_hs_dur": 208809082, // handshake duration in nanosecons.
    "est_cxn_dur": 159857626, // time it took to establish connection with server in nanosecons.
    "ttfb": 998874037, // time since start of the request it took to recieve first byte.
    "req_dur": 999186595, // total request duration in nanoseconds
    "req_dur_str": "999.186595ms" // string of req_dur
  },
  "data": {
    "abs_slot": 52671876,
    "block_no": 6852764,
    "block_time": "2022-02-07T12:49:27",
    "epoch": 319,
    "epoch_slot": 227076,
    "hash": "1dad134750188460dd48068e655b5935403d2f51afaf53a39337a4c89771754a"
  }


Example to query testnet tip from cli
koios-rest --enable-req-stats --testnet tip
# OR
koios-rest --enable-req-stats --host testnet.koios.rest tip

response

{
  "request_url": "https://testnet.koios.rest/api/v0/tip",
  "request_method": "GET",
  "status_code": 200,
  "status": "200 OK",
  "date": "Mon, 07 Feb 2022 12:50:04 GMT",
  "content_range": "0-0/*",
  "stats": {
    "req_started_at": "2022-02-07T12:50:03.98615637Z",
    "req_dns_lookup_dur": 1383437,
    "tls_hs_dur": 69093093,
    "est_cxn_dur": 43733700,
    "ttfb": 167423049,
    "req_dur": 167738287,
    "req_dur_str": "167.738287ms"
  },
  "data": {
    "abs_slot": 49868948,
    "block_no": 3300758,
    "block_time": "2022-02-07T12:49:24",
    "epoch": 185,
    "epoch_slot": 318548,
    "hash": "d7623e68cb78f450f42ba4b5a169124b26677f08f676ca4241b27edb6dbf0071"
  }
}

Install

It's highly recommended installing a latest version of koios-rest available on the releases page.

Install from Source

Installing from source requires a working Go environment. See the install instructions for Go.

Since koios-rest cli application uses replace in ./cmd/koiso-rest/go.mod. Then go install won't work. To install it from source use following commands.

  1. git clone git@github.com:howijd/koios-rest-go-client.git
  2. cd ./koios-rest-go-client/cmd/koios-rest
  3. go install .

verify installation

koios-rest --version


Contributing

We would love for you to contribute to Koios API Client Library for Go and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow:

Code of Conduct

Help us keep Koios API Client Library for Go open and inclusive. Please read and follow our [Code of Conduct][code-of-conduc]


Got a Question or Problem?

Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on Koios Telegram Group


Issues and Bugs

If you find a bug in the source code, you can help us by submitting an issue to our GitHub Repository. Even better, you can submit a Pull Request with a fix.


Feature Requests

You can request a new feature by submitting an issue to our GitHub Repository. If you would like to implement a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it. Please consider what kind of change it is:

  • For a Major Feature, first open an issue and outline your proposal so that it can be discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project.
  • Small Features can be crafted and directly submitted as a Pull Request.

Submission Guidelines

Submitting an Issue

Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.

You can file new issues by filling out our new issue form.


Submitting a Pull Request (PR)

Before you submit your Pull Request (PR) consider the following guidelines:

  1. Search GitHub for an open or closed PR that relates to your submission. You don't want to duplicate effort.

  2. Fork the howijd/koios-rest-go-client repo.

  3. Setup you local repository

    git@github.com:<your-github-username>/koios-rest-go-client.git
    cd koios-rest-go-client
    git remote add upstream git@github.com:howijd/koios-rest-go-client.git
    
  4. Make your changes in a new git branch and ensure that you always start from up to date main branch. Repeat this step every time you are about to start woking on new PR.

    e.g. Start new change work to update readme:

    # if you are not in main branch e.g. still on previous work branch
    git checkout main
    git pull --ff upstream main
    git checkout -b update-readme main
    
  5. Create your patch, including appropriate test cases.

  6. Follow our Coding Rules.

  7. If changes are in source code except documentations then run the full test suite, as described in the developer documentation, and ensure that all tests pass.

  8. Commit your changes using a descriptive commit message that follows our commit message conventions. Adherence to these conventions is necessary because release notes are automatically generated from these messages.

    git add -A
    git commit --signoff
    # or in short
    git commit -sm"docs(markdown): update readme examples"
    
  9. Push your branch to GitHub:

    git push -u origin update-readme
    
  10. In GitHub, send a pull request to main branch.

  • If we suggest changes then:
    • Make the required updates.

    • Re-run the test suites to ensure tests are still passing.

    • Rebase your branch and force push to your GitHub repository (this will update your Pull Request):

      git fetch --all
      git rebase upstream main
      git push -uf origin update-readme
      

That's it! Thank you for your contribution!


After your pull request is merged

After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository:

  • Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:

    git push origin --delete update-readme
    
  • Check out the main branch:

    git checkout main -f
    
  • Delete the local branch:

    git branch -D update-readme
    
  • Update your master with the latest upstream version:

    git pull --ff upstream main
    

Coding Rules

To ensure consistency throughout the source code, keep these rules in mind as you are working:

  • All features or bug fixes must be tested by one or more specs (unit-tests).
  • All public API methods must be documented.

Commit Message Guidelines

Conventional Commits

We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. Commit messages should be well formatted, and to make that "standardized", we are using Conventional Commits. Our release workflow uses these rules to generate changelogs.


Commit Message Format

Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

When maintainers are merging PR merge commit should be edited:

<type>(<scope>): <subject> (#pr)
<BLANK LINE>
<body>
<BLANK LINE>
<footer>

The header is mandatory and the scope of the header is optional.

Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.

The footer should contain a closing reference to an issue if any.

Samples:

docs(markdown): update readme examples
fix(cli): fix cli command get action

description of your change.
refactor(client): change Client GET function signature

change order of client GET method arguments.

BREAKING CHANGE: Clien.Get signature has changed

Revert

If the commit reverts a previous commit, it should begin with revert: , followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>., where the hash is the SHA of the commit being reverted.


Type

Must be one of the following:

  • build: Changes that affect the build system or external dependencies (example scopes: goreleaser)
  • chore: Other changes that don't modify src or test files.
  • ci: Changes to our CI configuration files and scripts.
  • dep: Changes related to dependecies e.g. go.mod
  • docs: Documentation only changes (example scopes: markdown, godoc)
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Reverts a previous commit
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

Scope

The following is the list of supported scopes:

scope description
cli CLI app related changes
client API client related changes
endpoint Changes related to api endpoints
godoc Go documentation
markdown Markdown files
packaging Used for changes that change the release packages

Subject

The subject contains a succinct description of the change:

  • use the imperative, present tense: "change" not "changed" nor "changes"
  • don't capitalize the first letter
  • no dot (.) at the end
Body

Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.

The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.

Breaking Changes should start with the word BREAKING CHANGE: with a space or two newlines. The rest of the commit message is then used for this.

A detailed explanation can be found in this [document][commit-message-format].


Development Documentation

Setup your machine

Prerequisites:

  • Working Go environment. See the install instructions for Go.

  • golangci-lint - Go linters aggregator should be installed

  • taskfile - task runner / build tool should be installed

  • svu - Semantic Version Util tool should be installed

  • Fork the howijd/koios-rest-go-client repo.

  • Setup you local repository

    git@github.com:<your-github-username>/koios-rest-go-client.git
    cd koios-rest-go-client
    git remote add upstream git@github.com:howijd/koios-rest-go-client.git
    

Setup local env

task setup

Lint your code

task lint

Test your change

task test

View code coverage report from in browser (results from task test)

task cover

Build snapshot binaries to ./cmd/koios-rest/dist.

use it if you want to test release packages

task build:snapshot

Documentation

Overview

Package koios provides api client library to interact with Koios API endpoints and Cardano Blockchain. Sub package ./cmd/koios-rest provides cli application.

Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc.

Index

Constants

View Source
const (
	MainnetHost              = "api.koios.rest"
	GuildHost                = "guild.koios.rest"
	TestnetHost              = "testnet.koios.rest"
	DefaultAPIVersion        = "v0"
	DefaultPort       uint16 = 443
	DefaultSchema            = "https"
	LibraryVersion           = "v0"
	DefaultRateLimit  uint8  = 5
	DefaultOrigin            = "https://github.com/howijd/koios-rest-go-client"
)

MainnetHost : is primay and default api host. GuildHost : is Guild network host. TestnetHost : is api host for testnet. DefaultAPIVersion : is openapi spec version e.g. /v0. DefaultPort : default port used by api client. DefaultSchema : default schema used by api client. LibraryVersion : koios go library version. DefaultRateLimit : is default rate limit used by api client. DefaultOrigin : is default origin header used by api client.

Variables

View Source
var (
	ErrURLValuesLenght          = errors.New("if presenent then only single url.Values should be provided")
	ErrHTTPClientTimeoutSetting = errors.New("http.Client.Timeout should never be 0 in production")
	ErrHTTPClientChange         = errors.New("http.Client can only be set as option to koios.New")
	ErrOriginSet                = errors.New("origin can only be set as option to koios.New")
	ErrRateLimitRange           = errors.New("rate limit must be between 1-255 requests per sec")
	ErrResponseIsNotJSON        = errors.New("go non json response")
	ErrNoTxHash                 = errors.New("missing transaxtion hash(es)")
	ErrNoAddress                = errors.New("missing address")
	ErrNoPoolID                 = errors.New("missing pool id")
)

Predefined errors used by the library.

Functions

This section is empty.

Types

type AccountAction

type AccountAction struct {
	ActionType string `json:"action_type"`
	TxHash     TxHash `json:"tx_hash"`
}

AccountAction data entry for `/account_updates`.

type AccountAddressesResponse

type AccountAddressesResponse struct {
	Response
	Data []Address `json:"response"`
}

AccountAddressesResponse represents response from `/account_addresses` endpoint.

type AccountAsset

type AccountAsset struct {
	// Name Asset Name (hex).
	Name string `json:"asset_name"`

	// PolicyID Asset Policy ID (hex).
	PolicyID PolicyID `json:"asset_policy"`

	// Quantity of assets
	Quantity Lovelace `json:"quantity"`
}

AccountAsset.

type AccountAssetsResponse

type AccountAssetsResponse struct {
	Response
	Data []AccountAsset `json:"response"`
}

AccountAssetsResponse represents response from `/account_assets` endpoint.

type AccountHistoryEntry

type AccountHistoryEntry struct {
	StakeAddress StakeAddress `json:"stake_address"`
	PoolID       PoolID       `json:"pool_id"`
	Epoch        EpochNo      `json:"epoch_no"`
	ActiveStake  Lovelace     `json:"active_stake"`
}

type AccountHistoryResponse

type AccountHistoryResponse struct {
	Response
	Data []AccountHistoryEntry `json:"response"`
}

AccountHistoryResponse represents response from `/account_history` endpoint.

type AccountInfo

type AccountInfo struct {
	Status           string   `json:"status"`
	DelegatedPool    PoolID   `json:"delegated_pool"`
	TotalBalance     Lovelace `json:"total_balance"`
	UTxO             Lovelace `json:"utxo"`
	Rewards          Lovelace `json:"rewards"`
	Withdrawals      Lovelace `json:"withdrawals"`
	RewardsAvailable Lovelace `json:"rewards_available"`
	Reserves         Lovelace `json:"reserves"`
	Treasury         Lovelace `json:"treasury"`
}

AccountInfo data returned by `/account_info`.

type AccountInfoResponse

type AccountInfoResponse struct {
	Response
	Data *AccountInfo `json:"response"`
}

AccountInfoResponse represents response from `/account_info` endpoint.

type AccountListResponse

type AccountListResponse struct {
	Response
	Data []StakeAddress `json:"response"`
}

AccountListResponse represents response from `/account_list` endpoint.

type AccountRewards

type AccountRewards struct {
	PoolID         PoolID   `json:"pool_id"`
	EarnedEpoch    EpochNo  `json:"earned_epoch"`
	SpendableEpoch EpochNo  `json:"spendable_epoch"`
	Amount         Lovelace `json:"amount"`
	Type           string   `json:"type"`
}

AccountRewards data returned by `/account_rewards`.

type AccountRewardsResponse

type AccountRewardsResponse struct {
	Response
	Data []AccountRewards `json:"response"`
}

AccountRewardsResponse represents response from `/account_rewards` endpoint.

type AccountUpdatesResponse

type AccountUpdatesResponse struct {
	Response
	Data []AccountAction `json:"response"`
}

AccountUpdatesResponse represents response from `/account_rewards` endpoint.

type Address

type Address string

Address defines type for _address.

type AddressAsset

type AddressAsset struct {
	// Asset Name (hex).
	NameHEX string `json:"asset_name_hex"`

	// Asset Policy ID (hex).
	PolicyID PolicyID `json:"asset_policy_hex"`

	// Quantity of asset accoiated to the given address.
	Quantity Lovelace `json:"quantity"`
}

AddressAsset payload item returned by.

type AddressAssetsResponse

type AddressAssetsResponse struct {
	Response
	Data []AddressAsset `json:"response"`
}

AddressAssetsResponse represents response from `/address_info` endpoint.

type AddressInfo

type AddressInfo struct {
	// Balance ADA Lovelace balance of address
	Balance Lovelace `json:"balance"`

	// StakeAddress associated with address
	StakeAddress StakeAddress `json:"stake_address,omitempty"`

	UTxOs []AddressUTxO `json:"utxo_set"`
}

AddressInfo esponse for `/address_info`.

type AddressInfoResponse

type AddressInfoResponse struct {
	Response
	Data *AddressInfo `json:"response"`
}

AddressInfoResponse represents response from `/address_info` endpoint.

type AddressTxsResponse

type AddressTxsResponse struct {
	Response
	Data []TxHash `json:"response"`
}

AddressTxsResponse represents response from `/address_txs` endpoint.

type AddressUTxO

type AddressUTxO struct {
	// Hash of Transaction for input UTxO.
	TxHash TxHash `json:"tx_hash"`

	// Index of input UTxO on the mentioned address used for input.
	TxIndex int `json:"tx_index"`

	// Balance on the selected input transaction.
	Value Lovelace `json:"value"`

	// An array of assets contained on UTxO.
	AssetList []Asset `json:"asset_list"`
}

AddressUTxO UTxO attached to address.

type Asset

type Asset struct {
	// Asset Name (hex).
	Name string `json:"asset_name"`

	// Asset Policy ID (hex).
	PolicyID PolicyID `json:"policy_id"`

	// Quantity
	// Input: asset balance on the selected input transaction.
	// Output: sum of assets for output UTxO.
	// Mint: sum of minted assets (negative on burn).
	Quantity Lovelace `json:"quantity"`
}

Asset.

type AssetAddressListResponse

type AssetAddressListResponse struct {
	Response
	Data []AssetHolder `json:"response"`
}

AssetAddressListResponse represents response from `/asset_address_list` endpoint.

type AssetHolder

type AssetHolder struct {
	PaymentAddress Address  `json:"payment_address"`
	Quantity       Lovelace `json:"quantity"`
}

AssetHolder payment addresses holding the given token (including balance).

type AssetInfo

type AssetInfo struct {
	// Asset Name (hex).
	Name string `json:"asset_name"`

	// Asset Name (ASCII)
	NameASCII string `json:"asset_name_ascii"`

	// The CIP14 fingerprint of the asset
	Fingerprint string `json:"fingerprint"`

	// MintingTxMetadata minting Tx JSON payload if it can be decoded as JSON
	MintingTxMetadata *TxInfoMetadata `json:"minting_tx_metadata"`

	// Asset metadata registered on the Cardano Token Registry
	TokenRegistryMetadata *TokenRegistryMetadata `json:"token_registry_metadata"`

	// Asset Policy ID (hex).
	PolicyID PolicyID `json:"policy_id"`

	// TotalSupply of Asset
	TotalSupply Lovelace `json:"total_supply"`

	// CreationTime of Asset
	CreationTime string `json:"creation_time"`
}

AssetInfo info about the asset.

type AssetInfoResponse

type AssetInfoResponse struct {
	Data *AssetInfo `json:"response"`
	Response
}

AssetInfoResponse represents response from `/asset_info` endpoint.

type AssetListItem

type AssetListItem struct {
	PolicyID   PolicyID `json:"policy_id"`
	AssetNames struct {
		HEX   []string `json:"hex"`
		ASCII []string `json:"ascii"`
	} `json:"asset_names"`
}

AssetListItem used to represent response from /asset_list`.

type AssetListResponse

type AssetListResponse struct {
	Response
	Data []AssetListItem `json:"response"`
}

AssetListResponse represents response from `/asset_list` endpoint.

type AssetName

type AssetName string

AssetName defines type for _asset_name.

type AssetSummary

type AssetSummary struct {
	// Asset Name (hex)
	AssetName string `json:"asset_name"`

	// Asset Policy ID (hex)
	PolicyID PolicyID `json:"policy_id"`

	// Total number of registered wallets holding the given asset
	StakedWallets int64 `json:"staked_wallets"`

	// Total number of transactions including the given asset
	TotalTransactions int64 `json:"total_transactions"`

	// Total number of payment addresses (not belonging
	// to registered wallets) holding the given asset
	UnstakedAddresses int64 `json:"unstaked_addresses"`
}

AssetSummary aggregated asset summary.

type AssetSummaryResponse

type AssetSummaryResponse struct {
	Response
	Data *AssetSummary `json:"response"`
}

AssetSummaryResponse represents response from `/asset_summary` endpoint.

type AssetTxs

type AssetTxs struct {
	// AssetName (hex)
	AssetName string `json:"asset_name"`

	// PoliciID Asset Policy ID (hex)
	PolicyID PolicyID `json:"policy_id"`

	// TxHashes List of Tx hashes
	TxHashes []TxHash `json:"tx_hashes"`
}

AssetTxs Txs info for the given asset (latest first).

type AssetTxsResponse

type AssetTxsResponse struct {
	Response
	Data *AssetTxs `json:"response"`
}

AssetTxsResponse represents response from `/asset_txs` endpoint.

type Block

type Block struct {
	// Hash block hash
	Hash BlockHash `json:"hash"`

	// Epoch number.
	Epoch EpochNo `json:"epoch"`

	// AbsoluteSlot is overall slot number (slots from genesis block of chain).
	AbsoluteSlot int `json:"abs_slot"`

	// EpochSlot slot number within epoch.
	EpochSlot int `json:"epoch_slot"`

	// Height is block number on chain where transaction was included.
	Height int `json:"height"`

	// Size of block.
	Size int `json:"size"`

	// Time time of the block.
	Time string `json:"block_time"`

	// TxCount transactions count in block.
	TxCount int `json:"tx_count"`

	// VrfKey is pool VRF key.
	VrfKey string `json:"vrf_key"`

	// OpCert latest ool operational certificate hash
	OpCert string `json:"op_cert,omitempty"`

	// Pool ID.
	Pool string `json:"pool"`

	// OpCertCounter is pool latest operational certificate counter value.
	OpCertCounter int `json:"op_cert_counter"`

	// ParentHash parent block hash
	ParentHash BlockHash `json:"parent_hash,omitempty"`

	// ChildHash child block hash
	ChildHash BlockHash `json:"child_hash,omitempty"`
}

Block defines model for block.

type BlockHash

type BlockHash string

BlockHash defines type for _block_hash.

type BlockInfoResponse

type BlockInfoResponse struct {
	Response
	Data *Block `json:"data"`
}

BlockInfoResponse represents response from `/block_info` endpoint.

type BlockTxsHashesResponse

type BlockTxsHashesResponse struct {
	Response
	Data []TxHash `json:"data"`
}

BlockTxsHashesResponse represents response from `/block_txs` endpoint.

type BlocksResponse

type BlocksResponse struct {
	Response
	Data []Block `json:"data"`
}

BlocksResponse represents response from `/blocks` endpoint.

type Certificate

type Certificate struct {
	// Index of the certificate
	Index int `json:"index"`

	// Info is A JSON object containing information from the certificate.
	Info map[string]interface{} `json:"info"`

	// Type of certificate could be:
	// delegation, stake_registration, stake_deregistraion, pool_update,
	// pool_retire, param_proposal, reserve_MIR, treasury_MIR).
	Type string `json:"type"`
}

Certificate information.

type Client

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

Client is api client instance.

func New

func New(opts ...Option) (*Client, error)

New creates thread-safe API client you can freerly pass this client to multiple go routines.

Call to New without options is same as call with default options. e.g. api, err := koios.New(

koios.Host(koios.MainnetHost),
koios.APIVersion(koios.DefaultAPIVersion),
koios.Port(koios.DefaultPort),
koios.Schema(koios.DefaultSchema),
koios.HttpClient(koios.DefaultHttpClient),

).

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns currently used base url e.g. https://api.koios.rest/api/v0

func (*Client) GET

func (c *Client) GET(
	ctx context.Context,
	path string,
	query url.Values,
	headers http.Header,
) (*http.Response, error)

GET sends api http GET request to provided relative path with query params and returns an HTTP response. When using GET method you are expected to handle the response according to net/http.Do documentation. e.g. Caller should close resp.Body when done reading from it.

func (*Client) GetAccountAddresses

func (c *Client) GetAccountAddresses(
	ctx context.Context,
	addr StakeAddress,
) (res *AccountAddressesResponse, err error)

GetAccountAddresses retruns all addresses associated with an account.

func (*Client) GetAccountAssets

func (c *Client) GetAccountAssets(
	ctx context.Context,
	addr StakeAddress,
) (res *AccountAssetsResponse, err error)

GetAccountAssets retruns all the native asset balance of an account.

func (*Client) GetAccountHistory

func (c *Client) GetAccountHistory(
	ctx context.Context,
	addr StakeAddress,
) (res *AccountHistoryResponse, err error)

GetAccountHistory retruns the staking history of an account.

func (*Client) GetAccountInfo

func (c *Client) GetAccountInfo(ctx context.Context, addr Address) (res *AccountInfoResponse, err error)

GetAccountInfo returns the account info of any (payment or staking) address. nolint: dupl

func (*Client) GetAccountList

func (c *Client) GetAccountList(ctx context.Context) (res *AccountListResponse, err error)

GetTip returns the tip info about the latest block seen by chain.

func (*Client) GetAccountRewards

func (c *Client) GetAccountRewards(
	ctx context.Context,
	addr StakeAddress,
	epoch *EpochNo,
) (res *AccountRewardsResponse, err error)

GetAccountRewards retruns the full rewards history (including MIR) for a stake address, or certain epoch if specified.

func (*Client) GetAccountUpdates

func (c *Client) GetAccountUpdates(
	ctx context.Context,
	addr StakeAddress,
) (res *AccountUpdatesResponse, err error)

GetAccountUpdates (History) retruns the account updates (registration, deregistration, delegation and withdrawals).

func (*Client) GetAddressAssets

func (c *Client) GetAddressAssets(ctx context.Context, addr Address) (res *AddressAssetsResponse, err error)

GetAddressAssets returns the list of all the assets (policy, name and quantity) for a given address.

func (*Client) GetAddressInfo

func (c *Client) GetAddressInfo(ctx context.Context, addr Address) (res *AddressInfoResponse, err error)

GetAddressInfo returns address info - balance, associated stake address (if any) and UTxO set. nolint: dupl

func (*Client) GetAddressTxs

func (c *Client) GetAddressTxs(ctx context.Context, addrs []Address, h uint64) (res *AddressTxsResponse, err error)

GetAddressTxs returns the transaction hash list of input address array, optionally filtering after specified block height (inclusive). nolint: dupl

func (*Client) GetAssetAddressList

func (c *Client) GetAssetAddressList(
	ctx context.Context,
	policy PolicyID,
	name AssetName,
) (res *AssetAddressListResponse, err error)

GetAssetAddressList returns the list of all addresses holding a given asset.

func (*Client) GetAssetInfo

func (c *Client) GetAssetInfo(
	ctx context.Context,
	policy PolicyID,
	name AssetName,
) (res *AssetInfoResponse, err error)

GetAssetInfo returns the information of an asset including first minting & token registry metadata. nolint: dupl

func (*Client) GetAssetList

func (c *Client) GetAssetList(ctx context.Context) (res *AssetListResponse, err error)

GetTip returns the list of all native assets (paginated).

func (*Client) GetAssetSummary

func (c *Client) GetAssetSummary(
	ctx context.Context,
	policy PolicyID,
	name AssetName,
) (res *AssetSummaryResponse, err error)

GetAssetSummary returns the summary of an asset (total transactions exclude minting/total wallets include only wallets with asset balance). nolint: dupl

func (*Client) GetAssetTxs

func (c *Client) GetAssetTxs(
	ctx context.Context,
	policy PolicyID,
	name AssetName,
) (res *AssetTxsResponse, err error)

GetAssetTxs returns the list of all asset transaction hashes (newest first). nolint: dupl

func (*Client) GetBlockInfo

func (c *Client) GetBlockInfo(ctx context.Context, hash BlockHash) (res *BlockInfoResponse, err error)

GetBlockInfo returns detailed information about a specific block.

func (*Client) GetBlockTxHashes

func (c *Client) GetBlockTxHashes(ctx context.Context, hash BlockHash) (res *BlockTxsHashesResponse, err error)

GetBlockTxHashes returns a list of all transactions hashes included in a provided block.

func (*Client) GetBlocks

func (c *Client) GetBlocks(ctx context.Context) (res *BlocksResponse, err error)

GetBlocks returns summarised details about all blocks (paginated - latest first).

func (*Client) GetCredentialTxs

func (c *Client) GetCredentialTxs(
	ctx context.Context,
	creds []PaymentCredential,
	h uint64,
) (res *CredentialTxsResponse, err error)

GetCredentialTxs returns the transaction hash list of input payment credential array, optionally filtering after specified block height (inclusive). nolint: dupl

func (*Client) GetEpochInfo

func (c *Client) GetEpochInfo(ctx context.Context, epoch *EpochNo) (res *EpochInfoResponse, err error)

GetEpochInfo returns the epoch information, all epochs if no epoch specified.

func (*Client) GetEpochParams

func (c *Client) GetEpochParams(ctx context.Context, epoch *EpochNo) (res *EpochParamsResponse, err error)

GetEpochParams returns the protocol parameters for specific epoch, and information about all epochs if no epoch specified.

func (*Client) GetGenesis

func (c *Client) GetGenesis(ctx context.Context) (res *GenesisResponse, err error)

GetGenesis returns the Genesis parameters used to start specific era on chain.

func (*Client) GetPoolBlocks

func (c *Client) GetPoolBlocks(
	ctx context.Context,
	pid PoolID,
	epoch *EpochNo,
) (res *PoolBlocksResponse, err error)

GetPoolBlocks returns information about blocks minted by a given pool in current epoch (or _epoch_no if provided).

func (*Client) GetPoolDelegators

func (c *Client) GetPoolDelegators(
	ctx context.Context,
	pid PoolID,
	epoch *EpochNo,
) (res *PoolDelegatorsResponse, err error)

GetPoolDelegators returns information about delegators by a given pool and optional epoch (current if omitted).

func (*Client) GetPoolInfo

func (c *Client) GetPoolInfo(ctx context.Context, pid PoolID) (res *PoolInfoResponse, err error)

GetPoolInfo returns current pool status and details for a specified pool.

func (*Client) GetPoolInfos

func (c *Client) GetPoolInfos(ctx context.Context, pids []PoolID) (res *PoolInfosResponse, err error)

GetTxsInfos returns current pool statuses and details for a specified list of pool ids.

func (*Client) GetPoolList

func (c *Client) GetPoolList(ctx context.Context) (res *PoolListResponse, err error)

GetPoolList returns the list of all currently registered/retiring (not retired) pools.

func (*Client) GetPoolMetadata

func (c *Client) GetPoolMetadata(ctx context.Context) (res *PoolMetadataResponse, err error)

GetPoolMetadata returns Metadata(on & off-chain) for all currently registered/retiring (not retired) pools.

func (*Client) GetPoolRelays

func (c *Client) GetPoolRelays(ctx context.Context) (res *PoolRelaysResponse, err error)

GetPoolRelays returns a list of registered relays for all currently registered/retiring (not retired) pools.

func (*Client) GetPoolUpdates

func (c *Client) GetPoolUpdates(
	ctx context.Context,
	pid *PoolID,
) (res *PoolUpdatesResponse, err error)

GetPoolUpdates returns all pool updates for all pools or only updates for specific pool if specified.

func (*Client) GetScriptList

func (c *Client) GetScriptList(ctx context.Context) (res *ScriptListResponse, err error)

GetScriptList returns the list of all existing script hashes along with their creation transaction hashes.

func (*Client) GetScriptRedeemers

func (c *Client) GetScriptRedeemers(
	ctx context.Context,
	sh ScriptHash,
) (res *ScriptRedeemersResponse, err error)

GetScriptRedeemers returns a list of all redeemers for a given script hash.

func (*Client) GetTip

func (c *Client) GetTip(ctx context.Context) (res *TipResponse, err error)

GetTip returns the tip info about the latest block seen by chain.

func (*Client) GetTotals

func (c *Client) GetTotals(ctx context.Context, epoch *EpochNo) (res *TotalsResponse, err error)

GetTotals returns the circulating utxo, treasury, rewards, supply and reserves in lovelace for specified epoch, all epochs if empty.

func (*Client) GetTxInfo

func (c *Client) GetTxInfo(ctx context.Context, tx TxHash) (res *TxInfoResponse, err error)

GetTxInfo returns detailed information about transaction.

func (*Client) GetTxMetaLabels

func (c *Client) GetTxMetaLabels(ctx context.Context) (res *TxMetaLabelsResponse, err error)

GetTxMetadataLabels retruns a list of all transaction metalabels.

func (*Client) GetTxMetadata

func (c *Client) GetTxMetadata(ctx context.Context, tx TxHash) (res *TxMetadataResponse, err error)

GetTxMetadata returns metadata information (if any) for given transaction.

func (*Client) GetTxStatus

func (c *Client) GetTxStatus(ctx context.Context, tx TxHash) (res *TxStatusResponse, err error)

GetTxInfo returns detailed information about transaction.

func (*Client) GetTxsInfos

func (c *Client) GetTxsInfos(ctx context.Context, txs []TxHash) (res *TxsInfosResponse, err error)

GetTxsInfos returns detailed information about transaction(s).

func (*Client) GetTxsMetadata

func (c *Client) GetTxsMetadata(ctx context.Context, txs []TxHash) (res *TxsMetadataResponse, err error)

GetTxsInfos returns detailed information about transaction(s).

func (*Client) GetTxsStatuses

func (c *Client) GetTxsStatuses(ctx context.Context, txs []TxHash) (res *TxsStatusesResponse, err error)

GetTxsInfos returns detailed information about transaction(s).

func (*Client) GetTxsUTxOs

func (c *Client) GetTxsUTxOs(ctx context.Context, txs []TxHash) (res *TxUTxOsResponse, err error)

GetTxsUTxOs returns UTxO set (inputs/outputs) of transactions.

func (*Client) HEAD

func (c *Client) HEAD(
	ctx context.Context,
	path string,
	query url.Values,
	headers http.Header,
) (*http.Response, error)

HEAD sends api http HEAD request to provided relative path with query params and returns an HTTP response.

func (*Client) POST

func (c *Client) POST(
	ctx context.Context,
	path string,
	body io.Reader,
	query url.Values,
	headers http.Header,
) (*http.Response, error)

POST sends api http POST request to provided relative path with query params and returns an HTTP response. When using POST method you are expected to handle the response according to net/http.Do documentation. e.g. Caller should close resp.Body when done reading from it.

func (*Client) SubmitSignedTx

func (c *Client) SubmitSignedTx(ctx context.Context, stx TxBodyJSON) (res *SubmitSignedTxResponse, err error)

SubmitSignedTx Submit an transaction to the network.

func (*Client) TotalRequests

func (c *Client) TotalRequests() uint64

TotalRequests retruns number of total requests made by API client.

type CredentialTxsResponse

type CredentialTxsResponse struct {
	Response
	Data []TxHash `json:"response"`
}

CredentialTxsResponse represents response from `/credential_txs` endpoint.

type EpochInfo

type EpochInfo struct {
	// Rewards accumulated as of given epoch (in lovelaces)
	ActiveStake string `json:"active_stake"`

	// Number of blocks created in epoch
	BlkCount int `json:"blk_count"`

	// Epoch number
	Epoch EpochNo `json:"epoch_no"`

	// Total fees incurred by transactions in epoch
	Fees Lovelace `json:"fees"`

	// Timestamp for first block created in epoch
	FirstBlockTime string `json:"first_block_time"`

	// Timestamp for last block created in epoch
	LastBlockTime string `json:"last_block_time"`

	// Total output value across all transactions in epoch
	OutSum Lovelace `json:"out_sum"`

	// Number of transactions submitted in epoch
	TxCount int `json:"tx_count"`
}

EpochInfo defines model for epoch_info.

type EpochInfoResponse

type EpochInfoResponse struct {
	Response
	Data []EpochInfo `json:"data"`
}

EpochInfoResponse response of /epoch_info.

type EpochNo

type EpochNo uint64

EpochNo defines type for _epoch_no.

type EpochParams

type EpochParams struct {
	// The hash of the first block where these parameters are valid
	BlockHash string `json:"block_hash"`

	// The cost per UTxO word
	CoinsPerUtxoWord Lovelace `json:"coins_per_utxo_word"`

	// The percentage of the tx fee which must be provided as collateral
	// when including non-native scripts
	CollateralPercent int `json:"collateral_percent"`

	// The per language cost models
	CostModels string `json:"cost_models"`

	// The decentralisation parameter (1 fully centralised, 0 fully decentralised)
	Decentralisation float64 `json:"decentralisation"`

	// The hash of 32-byte string of extra random-ness added into
	// the protocol's entropy pool
	Entropy string `json:"entropy"`

	// Epoch number
	Epoch EpochNo `json:"epoch_no"`

	// The pledge influence on pool rewards
	Influence float64 `json:"influence"`

	// The amount (in lovelace) required for a deposit to register a stake address
	KeyDeposit Lovelace `json:"key_deposit"`

	// The maximum block header size (in bytes)
	MaxBhSize int `json:"max_bh_size"`

	// The maximum number of execution memory allowed to be used in a single block
	MaxBlockExMem float32 `json:"max_block_ex_mem"`

	// The maximum number of execution steps allowed to be used in a single block
	MaxBlockExSteps float32 `json:"max_block_ex_steps"`

	// The maximum block size (in bytes)
	MaxBlockSize int `json:"max_block_size"`

	// The maximum number of collateral inputs allowed in a transaction
	MaxCollateralInputs int `json:"max_collateral_inputs"`

	// The maximum number of epochs in the future that a pool retirement
	// is allowed to be scheduled for
	MaxEpoch int `json:"max_epoch"`

	// The maximum number of execution memory allowed to be used in a single transaction
	MaxTxExMem float32 `json:"max_tx_ex_mem"`

	// The maximum number of execution steps allowed to be used in a single transaction
	MaxTxExSteps float32 `json:"max_tx_ex_steps"`

	// The maximum transaction size (in bytes)
	MaxTxSize int `json:"max_tx_size"`

	// The maximum Val size
	MaxValSize float32 `json:"max_val_size"`

	// The 'a' parameter to calculate the minimum transaction fee
	MinFeeA int `json:"min_fee_a"`

	// The 'b' parameter to calculate the minimum transaction fee
	MinFeeB int `json:"min_fee_b"`

	// The minimum pool cost
	MinPoolCost Lovelace `json:"min_pool_cost"`

	// The minimum value of a UTxO entry
	MinUtxoValue int `json:"min_utxo_value"`

	// The monetary expansion rate
	MonetaryExpandRate float64 `json:"monetary_expand_rate"`

	// The nonce value for this epoch
	Nonce string `json:"nonce"`

	// The optimal number of stake pools
	OptimalPoolCount int `json:"optimal_pool_count"`

	// The amount (in lovelace) required for a deposit to register a stake pool
	PoolDeposit Lovelace `json:"pool_deposit"`

	// The per word cost of script memory usage
	PriceMem float64 `json:"price_mem"`

	// The cost of script execution step usage
	PriceStep float64 `json:"price_step"`

	// The protocol major version
	ProtocolMajor int `json:"protocol_major"`

	// The protocol minor version
	ProtocolMinor int `json:"protocol_minor"`

	// The treasury growth rate
	TreasuryGrowthRate float64 `json:"treasury_growth_rate"`
}

EpochParams defines model for epoch_params.

type EpochParamsResponse

type EpochParamsResponse struct {
	Response
	Data []EpochParams `json:"data"`
}

EpochParamsResponse response of /epoch_params.

type Genesis

type Genesis struct {
	// Active Slot Co-Efficient (f) - determines the _probability_ of number of
	// slots in epoch that are expected to have blocks
	// (so mainnet, this would be: 432000 * 0.05 = 21600 estimated blocks).
	Activeslotcoeff string `json:"activeslotcoeff"`

	// A JSON dump of Alonzo Genesis.
	Alonzogenesis string `json:"alonzogenesis"`

	// Number of slots in an epoch.
	Epochlength string `json:"epochlength"`

	// Number of KES key evolutions that will automatically occur before a KES
	// (hot) key is expired. This parameter is for security of a pool,
	// in case an operator had access to his hot(online) machine compromised.
	Maxkesrevolutions string `json:"maxkesrevolutions"`

	// Maximum smallest units (lovelaces) supply for the blockchain.
	Maxlovelacesupply string `json:"maxlovelacesupply"`

	// Network ID used at various CLI identification to distinguish between
	// Mainnet and other networks.
	Networkid string `json:"networkid"`

	// Unique network identifier for chain.
	Networkmagic string `json:"networkmagic"`

	// A unit (k) used to divide epochs to determine stability window
	// (used in security checks like ensuring atleast 1 block was
	// created in 3*k/f period, or to finalize next epoch's nonce
	// at 4*k/f slots before end of epoch).
	Securityparam string `json:"securityparam"`

	// Duration of a single slot (in seconds).
	Slotlength string `json:"slotlength"`

	// Number of slots that represent a single KES period
	// (a unit used for validation of KES key evolutions).
	Slotsperkesperiod string `json:"slotsperkesperiod"`

	// Timestamp for first block (genesis) on chain.
	Systemstart string `json:"systemstart"`

	// Number of BFT members that need to approve
	// (via vote) a Protocol Update Proposal.
	Updatequorum string `json:"updatequorum"`
}

Genesis defines model for genesis.

type GenesisResponse

type GenesisResponse struct {
	Response
	Data *Genesis `json:"data"`
}

GenesisResponse response of /genesis.

type Lovelace

type Lovelace struct {
	decimal.Decimal
}

Lovelace defines type for ADA lovelaces. This library uses forked snapshot of github.com/shopspring/decimal package to provide. JSON and XML serialization/deserialization and make it ease to work with calculations and deciimal precisions of ADA lovelace and native assets.

For API of decimal package see https://pkg.go.dev/github.com/shopspring/decimal

SEE: https://github.com/howijd/decimal issues and bug reports are welcome to: https://github.com/howijd/decimal/issues.

type Option

type Option func(*Client) error

Option is callback function which can be implemented to change configurations options of API Client.

func APIVersion

func APIVersion(version string) Option

APIVersion returns option apply func which can be used to change the baseurl api version https://api.koios.rest/api/<version>/

func CollectRequestsStats

func CollectRequestsStats(enabled bool) Option

CollectRequestsStats when enabled uses httptrace is used to collect detailed timing information about the request.

func HTTPClient

func HTTPClient(client *http.Client) Option

HTTPClient enables to set htt.Client to be used for requests. http.Client can only be set once.

func Host

func Host(host string) Option

Host returns option apply func which can be used to change the baseurl hostname https://<host>/api/v0/

func Origin

func Origin(origin string) Option

Origin sets Origin header for outgoing api requests. Recomoended is to set it to URL or FQDN of your project using this library.

In case you appliation goes rouge this could help to keep api.koios.rest service stable and up and running while temporary limiting requests it accepts from your application.

It's not required, but considered as good practice so that Cardano Community can provide HA services for Cardano ecosystem.

func Port

func Port(port uint16) Option

Port returns option apply func which can be used to change the baseurl port https://api.koios.rest:<port>/api/v0/

func RateLimit

func RateLimit(reqps uint8) Option

RateLimit sets requests per second this client is allowed to create and effectievely rate limits outgoing requests. Let's respect usage of the community provided resources.

func Schema

func Schema(schema string) Option

Schema returns option apply func which can be used to change the baseurl schema <schema>://api.koios.rest/api/v0/.

type PaymentAddr

type PaymentAddr struct {
	// Bech32 is Cardano payment/base address (bech32 encoded)
	// for transaction's or change to be returned.
	Bech32 string `json:"bech32"`

	// Payment credential.
	Cred PaymentCredential `json:"cred"`
}

PaymentAddr info.

type PaymentCredential

type PaymentCredential string

PaymentCredential.

type PolicyID

type PolicyID string

PolicyID.

type PoolBlockInfo

type PoolBlockInfo struct {
	// Hash block hash
	Hash BlockHash `json:"block_hash"`

	// Epoch number.
	Epoch EpochNo `json:"epoch_no"`

	// EpochSlot slot number within epoch.
	EpochSlot int `json:"epoch_slot_no"`

	// Slot is overall slot number (slots from genesis block of chain).
	Slot int `json:"slot_no"`

	// Time time of the block.
	Time string `json:"block_time"`

	// BlockNo is block number on chain.
	BlockNo uint64 `json:"block_no"`
}

PoolBlockInfo block info.

type PoolBlocksResponse

type PoolBlocksResponse struct {
	Response
	Data []PoolBlockInfo `json:"response"`
}

PoolInfoResponse represents response from `/pool_blocks` endpoint.

type PoolDelegator

type PoolDelegator struct {
	StakeAddress StakeAddress `json:"stake_address"`
	Amount       Lovelace     `json:"amount"`
	Epoch        EpochNo      `json:"epoch_no"`
}

PoolDelegator info.

type PoolDelegatorsResponse

type PoolDelegatorsResponse struct {
	Response
	Data []PoolDelegator `json:"response"`
}

PoolInfoResponse represents response from `/pool_delegators` endpoint.

type PoolID

type PoolID string

PoolID.

type PoolInfo

type PoolInfo struct {
	// ActiveEpochNo Block number on chain where transaction was included.
	ActiveEpoch EpochNo `json:"active_epoch_no"`

	// ActiveStake Pool active stake.
	ActiveStake Lovelace `json:"active_stake"`

	// Total pool blocks on chain
	BlockCount uint64 `json:"block_count"`

	// FixedCost Pool fixed cost per epoch
	FixedCost Lovelace `json:"fixed_cost"`

	// LiveDelegators Pool live delegator count
	LiveDelegators uint64 `json:"live_delegators"`

	// LiveSaturation Pool live saturation (decimal format)
	LiveSaturation float32 `json:"live_saturation"`

	// LiveStake Pool live stake
	LiveStake Lovelace `json:"live_stake"`

	// Margin (decimal format)
	Margin float32 `json:"margin"`

	// MetaHash Pool metadata hash
	MetaHash string `json:"meta_hash"`

	// MetaJson pool meta json
	MetaJSON PoolMetaJSON `json:"meta_json"`

	// MetaUrl Pool metadata URL
	MetaURL string `json:"meta_url"`

	// OpCert Pool latest operational certificate hash
	OpCert string `json:"op_cert"`

	// OpCertCounter Pool latest operational certificate counter value
	OpCertCounter int `json:"op_cert_counter"`

	// Owners of the pool
	Owners []StakeAddress `json:"owners"`

	// Pledge pledge in lovelace
	Pledge Lovelace `json:"pledge"`

	// ID (bech32 format)
	ID PoolID `json:"pool_id_bech32"`

	// IDHex Pool ID (Hex format)
	IDHex string `json:"pool_id_hex"`

	// Pool status (registered | retiring | retired)
	Status string `json:"pool_status"`

	// Announced retiring epoch (nullable)
	RetiringEpoch *EpochNo `json:"retiring_epoch"`

	// Pool reward address
	RewardAddr StakeAddress `json:"reward_addr"`

	// Pool VRF key hash
	VrfKeyHash string `json:"vrf_key_hash"`

	// Relays of the pool
	Relays []Relay `json:"relays"`
}

PoolInfo defines model for pool_info.

type PoolInfoResponse

type PoolInfoResponse struct {
	Response
	Data *PoolInfo `json:"response"`
}

PoolInfoResponse represents response from `/pool_info` endpoint. when requesting info about single pool.

type PoolInfosResponse

type PoolInfosResponse struct {
	Response
	Data []PoolInfo `json:"response"`
}

PoolInfosResponse represents response from `/pool_info` endpoint.

type PoolListItem

type PoolListItem struct {
	// PoolID Bech32 representation of pool ID.
	PoolID PoolID `json:"pool_id_bech32"`

	// Ticker of Pool.
	Ticker *string `json:"ticker,omitempty"`
}

PoolListItem defines model for pool list item.

type PoolListResponse

type PoolListResponse struct {
	Response
	Data []PoolListItem `json:"response"`
}

PoolListResponse represents response from `/pool_list` endpoint.

type PoolMetaJSON

type PoolMetaJSON struct {
	// Pool description
	Description *string `json:"description"`

	// Pool homepage URL
	Homepage *string `json:"homepage"`

	// Pool name
	Name *string `json:"name"`

	// Pool ticker
	Ticker *string `json:"ticker"`
}

PoolMetaJSON pool meadata json.

type PoolMetadata

type PoolMetadata struct {
	// ID (bech32 format)
	PoolID PoolID `json:"pool_id_bech32"`
	// MetaUrl Pool metadata URL
	MetaURL string `json:"meta_url"`

	// MetaHash Pool metadata hash
	MetaHash string `json:"meta_hash"`

	// MetaJson pool meta json
	MetaJSON PoolMetaJSON `json:"meta_json"`
}

PoolMeta metadata list item.

type PoolMetadataResponse

type PoolMetadataResponse struct {
	Response
	Data []PoolMetadata `json:"response"`
}

PoolMetadataResponse represents response from `/pool_metadata` endpoint.

type PoolRelays

type PoolRelays struct {
	PoolID PoolID `json:"pool_id_bech32"`
	// Relays of the pool.
	Relays []Relay `json:"relays"`
}

PoolRelays list item.

type PoolRelaysResponse

type PoolRelaysResponse struct {
	Response
	Data []PoolRelays `json:"response"`
}

PoolRelaysResponse represents response from `/pool_relays` endpoint.

type PoolUpdateInfo

type PoolUpdateInfo struct {
	// TxHash update transaction
	TxHash TxHash `json:"tx_hash"`

	// Time time of the block.
	BlockTime string `json:"block_time"`

	// ID (bech32 format)
	ID PoolID `json:"pool_id_bech32"`

	// IDHex Pool ID (Hex format)
	IDHex string `json:"pool_id_hex"`

	// ActiveEpochNo Block number on chain where transaction was included.
	ActiveEpoch EpochNo `json:"active_epoch_no"`

	// FixedCost Pool fixed cost per epoch
	FixedCost Lovelace `json:"fixed_cost"`

	// Margin (decimal format)
	Margin float32 `json:"margin"`

	// MetaHash Pool metadata hash
	MetaHash string `json:"meta_hash"`

	// MetaUrl Pool metadata URL
	MetaURL string `json:"meta_url"`

	// Owners of the pool.
	Owners []StakeAddress `json:"owners"`

	// Pledge pledge in lovelace.
	Pledge Lovelace `json:"pledge"`

	// Pool status (registered | retiring | retired).
	Status string `json:"pool_status"`

	// Announced retiring epoch (nullable).
	RetiringEpoch *EpochNo `json:"retiring_epoch"`

	// Pool reward address.
	RewardAddr StakeAddress `json:"reward_addr"`

	// Pool VRF key hash.
	VrfKeyHash string `json:"vrf_key_hash"`

	// Relays of the pool.
	Relays []PoolRelays `json:"relays"`
}

PoolUpdateInfo response item from `/pool_updates`.

type PoolUpdatesResponse

type PoolUpdatesResponse struct {
	Response
	Data []PoolUpdateInfo `json:"response"`
}

PoolUpdatesResponse represents response from `/pool_updates` endpoint.

type Relay

type Relay struct {
	// DNS name of the relay (nullable)
	DNS *string `json:"dns"`

	// IPv4 address of the relay (nullable)
	Ipv4 *string `json:"ipv4,"`

	// IPv6 address of the relay (nullable)
	Ipv6 *string `json:"ipv6,"`

	// Port number of the relay (nullable)
	Port *uint16 `json:"port"`

	// DNS service name of the relay (nullable)
	Srv *string `json:"srv"`
}

Relay defines model for pool relay.

type RequestStats

type RequestStats struct {
	// ReqStartedAt time when request was started.
	ReqStartedAt time.Time `json:"req_started_at,omitempty"`

	// DNSLookupDur DNS lookup duration.
	DNSLookupDur time.Duration `json:"req_dns_lookup_dur,omitempty"`

	// TLSHSDur time it took to perform TLS handshake.
	TLSHSDur time.Duration `json:"tls_hs_dur,omitempty"`

	// ESTCXNDur time it took to establish connection.
	ESTCXNDur time.Duration `json:"est_cxn_dur,omitempty"`

	// TTFB time it took to get the first byte of the response
	// after connextion was established.
	TTFB time.Duration `json:"ttfb,omitempty"`

	// ReqDur total time it took to peform the request.
	ReqDur time.Duration `json:"req_dur,omitempty"`

	// ReqDurStr String representation of ReqDur.
	ReqDurStr string `json:"req_dur_str,omitempty"`
}

RequestStats represent collected request stats if collecting request stats is enabled.

type Response

type Response struct {
	// RequestURL is full request url.
	RequestURL string `json:"request_url"`

	// RequestMethod is HTTP method used for request.
	RequestMethod string `json:"request_method"`

	// StatusCode of the HTTP response.
	StatusCode int `json:"status_code"`

	// Status of the HTTP response header if present.
	Status string `json:"status"`

	// Date response header.
	Date string `json:"date,omitempty"`

	// ContentLocation response header if present.
	ContentLocation string `json:"content_location,omitempty"`

	// ContentRange response header if present.
	ContentRange string `json:"content_range,omitempty"`

	// Error response body if present.
	Error *ResponseError `json:"error,omitempty"`

	// Stats of the request if stats are enabled.
	Stats *RequestStats `json:"stats,omitempty"`
}

Response wraps API responses.

type ResponseError

type ResponseError struct {
	// Hint of the error reported by server.
	Hint string `json:"hint,omitempty"`

	// Details of the error reported by server.
	Details string `json:"details,omitempty"`

	// Code is error code reported by server.
	Code string `json:"code,omitempty"`

	// Message is error message reported by server.
	Message string `json:"message,omitempty"`
}

ResponseError represents api error messages.

type ScriptHash

type ScriptHash string

ScriptHash defines type for _script_hash.

type ScriptListItem

type ScriptListItem struct {
	// Hash of the script creation transaction
	CreationTxHash TxHash `json:"creation_tx_hash"`

	// Hash of a script
	ScriptHash string `json:"script_hash"`
}

ScriptListItem item of script list.

type ScriptListResponse

type ScriptListResponse struct {
	Response
	Data []ScriptListItem `json:"response"`
}

ScriptListResponse represents response from `/script_list` endpoint.

type ScriptRedeemer

type ScriptRedeemer struct {
	// The Hash of the Plutus Data
	DatumHash string `json:"datum_hash"`

	// The actual data in json format
	DatumValue map[string]interface{} `json:"datum_value"`

	// The budget in fees to run a script - the fees depend on the
	// ExUnits and the current prices.
	Fee Lovelace `json:"fee,omitempty"`

	// What kind pf validation this redeemer is used for,
	// it can be one of 'spend', 'mint', 'cert', 'reward'.
	Purpose string `json:"purpose"`

	// TxHash of Transaction containing the redeemer.
	TxHash TxHash `json:"tx_hash"`

	// TxIndex The index of the redeemer pointer in the transaction.
	TxIndex int `json:"tx_index"`

	// The budget in Memory to run a script.
	UnitMem int `json:"unit_mem"`

	// The budget in Cpu steps to run a script.
	UnitSteps int `json:"unit_steps"`
}

ScriptRedeemer model.

type ScriptRedeemers

type ScriptRedeemers struct {
	// Hash of Transaction for which details are being shown
	ScriptHash ScriptHash `json:"script_hash"`

	// Redeemers list
	Redeemers []ScriptRedeemer `json:"redeemers"`
}

ScriptRedeemers defines model for script_redeemers.

type ScriptRedeemersResponse

type ScriptRedeemersResponse struct {
	Response
	Data *ScriptRedeemers `json:"response"`
}

ScriptRedeemersResponse represents response from `/script_redeemers` endpoint.

type StakeAddress

type StakeAddress string

StakeAddress is Cardano staking address (reward account, bech32 encoded).

type SubmitSignedTxResponse

type SubmitSignedTxResponse struct {
	Response
	Data TxHash `json:"data"`
}

SubmitSignedTxResponse represents response from `/submittx` endpoint.

type Tip

type Tip struct {
	// Absolute Slot number (slots not divided into epochs)
	AbsSlot int `json:"abs_slot"`

	// Block Height number on chain
	BlockNo int `json:"block_no"`

	// Timestamp for when the block was created
	BlockTime string `json:"block_time"`

	// Epoch number
	Epoch int `json:"epoch"`

	// Slot number within Epoch
	EpochSlot int `json:"epoch_slot"`

	// Block Hash in hex
	Hash string `json:"hash"`
}

Tip defines model for tip.

type TipResponse

type TipResponse struct {
	Response
	Data *Tip `json:"data"`
}

TipResponse response of /tip.

type TokenRegistryMetadata

type TokenRegistryMetadata struct {
	Decimals    int    `json:"decimals"`
	Description string `json:"description"`

	// A PNG image file as a byte string
	Name   string `json:"name"`
	Ticker string `json:"ticker"`
	URL    string `json:"url"`
}

Asset metadata registered on the Cardano Token Registry.

type Totals

type Totals struct {

	// Circulating UTxOs for given epoch (in lovelaces).
	Circulation Lovelace `json:"circulation"`

	// Epoch number.
	Epoch EpochNo `json:"epoch_no"`

	// Total Reserves yet to be unlocked on chain.
	Reserves Lovelace `json:"reserves"`

	// Rewards accumulated as of given epoch (in lovelaces).
	Reward Lovelace `json:"reward"`

	// Total Active Supply (sum of treasury funds, rewards,
	// UTxOs, deposits and fees) for given epoch (in lovelaces).
	Supply Lovelace `json:"supply"`

	// Funds in treasury for given epoch (in lovelaces).
	Treasury Lovelace `json:"treasury"`
}

Totals defines model for totals.

type TotalsResponse

type TotalsResponse struct {
	Response
	Data []Totals `json:"data"`
}

TotalsResponse represents response from `/totals` endpoint.

type TxBodyJSON

type TxBodyJSON struct {
	Type        string `json:"type"`
	Description string `json:"description"`
	CborHex     string `json:"cborHex"`
}

TxBodyJSON used to Unmarshal built transactions.

type TxHash

type TxHash string

TxHash defines type for tx_hash.

type TxInfo

type TxInfo struct {
	// TxHash is hash of transaction.
	TxHash TxHash `json:"tx_hash"`

	// BlockHash is hash of the block in which transaction was included.
	BlockHash BlockHash `json:"block_hash"`

	// BlockHeight is block number on chain where transaction was included.
	BlockHeight int `json:"block_height"`

	// Epoch number.
	Epoch EpochNo `json:"epoch"`

	// EpochSlot is slot number within epoch.
	EpochSlot int `json:"epoch_slot"`

	// AbsoluteSlot is overall slot number (slots from genesis block of chain).
	AbsoluteSlot int `json:"absolute_slot"`

	// TxTimestamp is timestamp when block containing transaction was created.
	TxTimestamp string `json:"tx_timestamp"`

	// TxBlockIndex is index of transaction within block.
	TxBlockIndex int `json:"tx_block_index"`

	// TxSize is transaction size in bytes.
	TxSize int `json:"tx_size"`

	// TotalOutput is total sum of all transaction outputs (in lovelaces).
	TotalOutput Lovelace `json:"total_output"`

	// Fee is total transaction fee (in lovelaces).
	Fee Lovelace `json:"fee"`

	// Deposit is total deposits included in transaction (for example,
	// if it is registering a pool/key).
	Deposit Lovelace `json:"deposit"`

	// InvalidAfter is slot number after which transaction cannot be validated.
	InvalidAfter int `json:"invalid_after,omitempty"`

	// InvalidBefore is slot number before which transaction cannot be validated.
	// (if supplied, else 0)
	InvalidBefore int `json:"invalid_before,omitempty"`

	// Inputs An array with details about inputs used in a transaction
	Inputs []TxInput `json:"inputs"`

	// Outputs An array with details about outputs from the transaction.
	Outputs []TxOutput `json:"outputs,omitempty"`

	// AssetsMinted An array of minted assets with-in a transaction (if any).
	AssetsMinted []Asset `json:"assets_minted"`

	// Collaterals An array of collateral inputs needed when dealing with smart contracts.
	Collaterals []TxInput `json:"collaterals"`

	// Metadata present with-in a transaction (if any)
	Metadata []TxInfoMetadata `json:"metadata"`

	// Array of withdrawals with-in a transaction (if any)
	Withdrawals []TxsWithdrawal `json:"withdrawals"`

	// Certificates present with-in a transaction (if any)
	Certificates []Certificate `json:"certificates"`
}

TxInfo transaction info.

type TxInfoMetadata

type TxInfoMetadata struct {
	// JSON containing details about metadata within transaction.
	JSON map[string]interface{} `json:"json"`

	// Key is metadata (index).
	Key int `json:"key"`
}

TxInfoMetadata metadata in transaction info.

type TxInfoResponse

type TxInfoResponse struct {
	Response
	Data *TxInfo `json:"response"`
}

TxsInfoResponse represents response from `/tx_info` endpoint. when requesting info about single transaction.

type TxInput

type TxInput struct {
	// An array of assets contained on input UTxO.
	AssetList []Asset `json:"asset_list"`

	// input UTxO.
	PaymentAddr PaymentAddr `json:"payment_addr"`

	// StakeAddress for transaction's input UTxO.
	StakeAddress StakeAddress `json:"stake_addr,omitempty"`

	// Hash of Transaction for input UTxO.
	TxHash TxHash `json:"tx_hash"`

	// Index of input UTxO on the mentioned address used for input.
	TxIndex int `json:"tx_index"`

	// Balance on the selected input transaction.
	Value Lovelace `json:"value"`
}

TxInput an transaxtion input.

type TxMetaLabelsResponse

type TxMetaLabelsResponse struct {
	Response
	Data []TxMetalabel `json:"data"`
}

TxMetaLabelsResponse represents response from `/tx_metalabels` endpoint.

type TxMetadata

type TxMetadata struct {
	// TxHash is hash of transaction.
	TxHash TxHash `json:"tx_hash"`
	// Metadata present with-in a transaction (if any)
	Metadata map[string]interface{} `json:"metadata"`
}

TxMetadata transaction metadata lookup res for `/tx_metadata` endpoint.

type TxMetadataResponse

type TxMetadataResponse struct {
	Response
	Data *TxMetadata `json:"data"`
}

TxMetadataResponse represents response from `/tx_metadata` endpoint.

type TxMetalabel

type TxMetalabel struct {
	// A distinct known metalabel
	Metalabel uint64 `json:"metalabel"`
}

TxMetalabels defines model for tx_metalabels.

type TxOutput

type TxOutput struct {
	// An array of assets to be included in output UTxO.
	AssetList []Asset `json:"asset_list"`

	// where funds were sent or change to be returned.
	PaymentAddr PaymentAddr `json:"payment_addr"`

	// StakeAddress for transaction's output UTxO.
	StakeAddress StakeAddress `json:"stake_addr,omitempty"`

	// Hash of this transaction.
	TxHash TxHash `json:"tx_hash"`

	// Index of output UTxO.
	TxIndex int `json:"tx_index"`

	// Total sum on the output address.
	Value Lovelace `json:"value"`
}

TxOutput an transaxtion output.

type TxStatus

type TxStatus struct {
	TxHash           TxHash `json:"tx_hash"`
	NumConfirmations uint64 `json:"num_confirmations"`
}

TxStatus is tx_status enpoint response.

type TxStatusResponse

type TxStatusResponse struct {
	Response
	Data *TxStatus `json:"response"`
}

TxStatusResponse represents response from `/tx_status` endpoint.

type TxUTxOsResponse

type TxUTxOsResponse struct {
	Response
	Data []UTxO `json:"data"`
}

TxUTxOsResponse represents response from `/tx_utxos` endpoint.

type TxsInfosResponse

type TxsInfosResponse struct {
	Response
	Data []TxInfo `json:"response"`
}

TxsInfoResponse represents response from `/tx_info` endpoint.

type TxsMetadataResponse

type TxsMetadataResponse struct {
	Response
	Data []TxMetadata `json:"data"`
}

TxsMetadataResponse represents response from `/tx_metadata` endpoint.

type TxsStatusesResponse

type TxsStatusesResponse struct {
	Response
	Data []TxStatus `json:"response"`
}

TxsStatusesResponse represents response from `/tx_status` endpoint.

type TxsWithdrawal

type TxsWithdrawal struct {
	// Amount is withdrawal amount in lovelaces.
	Amount Lovelace `json:"amount,omitempty"`
	// StakeAddress fo withdrawal.
	StakeAddress StakeAddress `json:"stake_addr,omitempty"`
}

TxsWithdrawal withdrawal record in transaction.

type UTxO

type UTxO struct {
	/// TxHash is hash of transaction.
	TxHash TxHash `json:"tx_hash"`

	// Inputs An array with details about inputs used in a transaction.
	Inputs []TxInput `json:"inputs"`
	// Outputs An array with details about outputs from the transaction.
	Outputs []TxOutput `json:"outputs"`
}

UTxO model holds inputs and outputs for given UTxO.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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