28

As a developer building an application, what are different way to access the Cardano network?

3 Answers 3

13

There are also ways to use services where you can make API requests to interact with the Cardano blockchain. (without the need to run your own cardano-node)

You could for example sign in on Blockfrost with your GitHub account. No registration required. Enter a project name and select Cardano mainnet or Cardano testnet, depending on your needs.

After generating your API KEY you can send your first request to get data for example about the latest epoch:

curl -H 'project_id: 1234567890' https://cardano-mainnet.blockfrost.io/api/v0/epochs/latest

And you will get a response in JSON format similar to this:

{ "epoch": 225, "start_time": 1603403091, "end_time": 1603835086, "first_block_time": 1603403092, "last_block_time": 1603835084, "block_count": 21298, "tx_count": 17856, "output": "7849943934049314", "fees": "4203312194", "active_stake": "784953934049314" }

Visit docs.blockfrost.io to see the complete API documentation.

22

If you use Nix or NixOs, it is rather straightforward: Build the code for a cardano node using nix (link to current documentation)

Duplicating the official documentation:

git clone https://github.com/input-output-hk/cardano-node
cd cardano-node
nix-build -A scripts.mainnet.node -o mainnet-node-local
./mainnet-node-local

This will run a cardano node on the mainnet.

Then you can also build and use the CLI tool to interact with the cardano network.


In the provided solution above, if you don't want to compile GHC which can take a long time, IOHK provides many binaries that are pre-compiled for you: lots of time gained ! So don't hesitate to use their nix binary cache

In NixOS, I currently set it this way:

# configuration.nix
{ config, pkgs, ... }:
{
  # ... all the rest of the configuration of the server

  # iohk binary caches
  nix = 
  {
    binaryCaches          = [ "https://hydra.iohk.io" "https://iohk.cachix.org" ];
    binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo=" ];
  };
}
3
  • 2
    Running this command "./mainnet-node-local" will download the whole blockchain or not?
    – vs4vijay
    Commented Apr 27, 2021 at 19:58
  • @vs4vijay when running this command, it creates a folder state-node-mainnet/db-mainnet which size increases overtime. I'm fairly confindent it is the state of the blockchain Commented Apr 29, 2021 at 8:10
  • 2
    This will get even nicer soon. It should become as simple as nix run github:input-output-hk/cardano-node/1.28.0#something. without even having to clone the repo locally. something isn't quite defined yet, but will be similar to the path building the script above. Commented Apr 30, 2021 at 4:03
10

Generally, there are several options you could pursue.

I'm sure there are lots of other possibilities that I haven't heard of or considered. There is no shortage of room to explore for a developer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.