https://github.com/blockfrost/blockfrost-erlang
Erlang SDK for Blockfrost.io
https://github.com/blockfrost/blockfrost-erlang
Last synced: 4 months ago
JSON representation
Erlang SDK for Blockfrost.io
- Host: GitHub
- URL: https://github.com/blockfrost/blockfrost-erlang
- Owner: blockfrost
- License: apache-2.0
- Created: 2023-12-29T07:59:46.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-02T20:20:28.000Z (over 1 year ago)
- Last Synced: 2025-12-26T20:30:11.074Z (6 months ago)
- Language: Erlang
- Size: 61.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://hex.pm/packages/blockfrost_erlang)
[](https://github.com/blockfrost/blockfrost-erlang/actions/workflows/ci.yaml)
[](https://fivebinaries.com/)

# blockfrost-erlang
Erlang SDK for Blockfrost.io API.
About •
Getting started •
Installation •
Usage
## About
Erlang SDK for the Blockfrost.io API.
## Getting started
To use this SDK, you first need to log in to [blockfrost.io](https://blockfrost.io), create your project and retrieve the API token.

## Installation
The SDK uses [rebar3](http://rebar3.org) for project management, [hackney](https://github.com/benoitc/hackney)
as its HTTP client and [jsx](https://github.com/talentdeficit/jsx/) for `JSON`
parsing.
You can either work directly with this repository or add this package as a dependency of your project using
```erlang
{deps, [
{blockfrost_erlang, "1.0.0"}
]}
```
To enter a development shell, use `nix-shell`.
## Usage
```sh
git clone https://github.com/blockfrost/blockfrost-erlang
cd blockfrost-erlang
nix-shell
rebar3 shell
```
If you export `BLOCKFROST_TOKEN_PATH` environment variable
`blockfrost-erlang` will automatically load
and configure network and token:
```sh
export BLOCKFROST_TOKEN_PATH=~/.blockfrost.mainnet.token
```
Then in `eshell`:
```erlang
blockfrost:get_blocks_latest().
{ok, Block} = blockfrost:get_blocks_latest().
Hash = maps:get(<<"hash">>, Block).
TxCount = maps:get(<<"tx_count">>, Block).
io:format("Block ~p tx count: ~p~n", [binary:bin_to_list(Hash), TxCount]).
```
Alternatively you can use `setup/1` function
which accepts a project string, for example
```erlang
blockfrost:setup("mainnet1A2B3C4D5E6F7G8H9I0J1K2L3M4N5O6P").
```
### `IPFS`
Simple `IPFS` upload example of a raw string:
```erlang
blockfrost:post_ipfs_add({multipart, [{<<"Filename">>, <<"Hello Erlang">>}]}).
```
See [hackney](https://github.com/benoitc/hackney#send-a-body) documentation
for more examples of `multipart` payload format.
## Maintenance
### Testing
Export a token
```sh
export BLOCKFROST_TOKEN_PATH=~/.blockfrost.mainnet.token
```
and run
```sh
rebar3 eunit
```
### Typecheck
Run `rebar3 dialyzer`
### Updating `rebar-deps.nix`
Run `rebar3 nix lock`