pg_cardano

A suite of Cardano-related tools

Overview

PackageVersionCategoryLicenseLanguage
pg_cardano1.2.0FEATMITRust
IDExtensionBinLibLoadCreateTrustRelocSchema
2920pg_cardanoNoYesNoYesNoNo-
Relatedage hll rum pg_graphql pg_jsonschema jsquery pg_hint_plan hypopg

PG18 fix by https://github.com/Vonng/pg_cardano

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.2.01817161514pg_cardano-
RPMPIGSTY1.2.01817161514pg_cardano_$v-
DEBPIGSTY1.2.01817161514postgresql-$v-pg-cardano-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
u22.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
u22.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
u24.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
u24.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1

Build

You can build the RPM / DEB packages for pg_cardano using pig build:

pig build pkg pg_cardano         # build RPM / DEB packages

Install

You can install pg_cardano directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_cardano;          # Install for current active PG version
pig ext install -y pg_cardano -v 18  # PG 18
pig ext install -y pg_cardano -v 17  # PG 17
pig ext install -y pg_cardano -v 16  # PG 16
pig ext install -y pg_cardano -v 15  # PG 15
dnf install -y pg_cardano_18       # PG 18
dnf install -y pg_cardano_17       # PG 17
dnf install -y pg_cardano_16       # PG 16
dnf install -y pg_cardano_15       # PG 15
apt install -y postgresql-18-pg-cardano   # PG 18
apt install -y postgresql-17-pg-cardano   # PG 17
apt install -y postgresql-16-pg-cardano   # PG 16
apt install -y postgresql-15-pg-cardano   # PG 15

Create Extension:

CREATE EXTENSION pg_cardano;

Usage

Sources: README, Cargo.toml version 1.2.0

pg_cardano is a Rust extension for Cardano-oriented binary and crypto utilities inside PostgreSQL. The upstream repo does not publish GitHub releases or tags, but the current crate version on the default branch is 1.2.0.

CREATE EXTENSION pg_cardano;

Core Capabilities

  • Base58 encode/decode.
  • Bech32 encode/decode.
  • CBOR to and from jsonb, with both simple and extended pipelines.
  • Blake2b hashing.
  • Ed25519 signing and signature verification.
  • dRep ID helpers for CIP-105 and CIP-129.
  • Shelley address builders and parsers.
  • Asset-name decoding and CIP-88 pool key registration verification.

Common Patterns

Base58 and Bech32:

SELECT cardano.base58_encode('Cardano'::bytea);
SELECT cardano.base58_decode('3Z6ioYHE3x');
SELECT cardano.bech32_encode('ada', 'is amazing'::bytea);
SELECT cardano.bech32_decode_prefix('ada1d9ejqctdv9axjmn8dypl4d');
SELECT cardano.bech32_decode_data('ada1d9ejqctdv9axjmn8dypl4d');

CBOR conversion:

SELECT cardano.cbor_decode_jsonb('\xa3636164616b...'::bytea);
SELECT cardano.cbor_encode_jsonb('{"ada": "is amazing!", "bytes": "\\xdeadbeef"}'::jsonb);
SELECT cardano.cbor_decode_jsonb_ext('\xa3636164616b...'::bytea);
SELECT cardano.cbor_encode_jsonb_ext('{"type":"map","value":[...]}'::jsonb);

Hashing and signatures:

SELECT cardano.blake2b_hash('Cardano is amazing!'::bytea, 32);
SELECT cardano.ed25519_verify_signature(
  '\x432753BD...'::bytea,
  'Cardano is amazing!'::bytea,
  '\x74265f96...'::bytea
);

Address and governance helpers:

SELECT cardano.tools_drep_id_encode_cip105('\x28111ae1...'::bytea, FALSE);
SELECT cardano.tools_drep_id_encode_cip129('\x28111ae1...'::bytea, TRUE);
SELECT cardano.tools_shelley_address_build(
  '\x7415251f...'::bytea, FALSE,
  '\x7c3ae2f2...'::bytea, FALSE,
  0
);
SELECT cardano.tools_shelley_addr_get_type('addr_test1vp6p2fgl...');

Caveats

  • Upstream documents PostgreSQL 12+ and Linux builds via pgrx; the crate features currently target PostgreSQL 15 through 18, with pg18 as the default feature.
  • The simple CBOR helpers are intentionally lossy for some CBOR constructs; use the *_ext functions when exact structural round-tripping matters.

Last Modified 2026-04-19: update extension stub docs (9f178c3)