Skip to content
pg_cardano

pg_cardano

pg_cardano : A suite of Cardano-related tools

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2920
pg_cardano
pg_cardano
1.2.0
FEAT
MIT
Rust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
See Also
age
hll
rum
pg_graphql
pg_jsonschema
jsquery
pg_hint_plan
hypopg

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.2.0
18
17
16
15
14
pg_cardano-
RPM
PIGSTY
1.2.0
18
17
16
15
14
pg_cardano_$v-
DEB
PIGSTY
1.2.0
18
17
16
15
14
postgresql-$v-pg-cardano-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
el8.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
el9.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
el9.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
el10.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
el10.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
d12.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
d12.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
d13.x86_64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.1.1
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
u26.x86_64
MISS
MISS
MISS
MISS
MISS
u26.aarch64
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
PIGSTY 1.2.0
MISS
PackageVersionOSORGSIZEFile URL
pg_cardano_181.2.0el8.x86_64pigsty518.4 KiBpg_cardano_18-1.2.0-1PIGSTY.el8.x86_64.rpm
pg_cardano_181.2.0el8.aarch64pigsty379.9 KiBpg_cardano_18-1.2.0-1PIGSTY.el8.aarch64.rpm
pg_cardano_181.2.0el9.x86_64pigsty536.6 KiBpg_cardano_18-1.2.0-1PIGSTY.el9.x86_64.rpm
pg_cardano_181.2.0el9.aarch64pigsty404.4 KiBpg_cardano_18-1.2.0-1PIGSTY.el9.aarch64.rpm
pg_cardano_181.2.0el10.x86_64pigsty537.0 KiBpg_cardano_18-1.2.0-1PIGSTY.el10.x86_64.rpm
pg_cardano_181.2.0el10.aarch64pigsty404.0 KiBpg_cardano_18-1.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-cardano1.2.0d12.x86_64pigsty434.7 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-cardano1.2.0d12.aarch64pigsty305.4 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-cardano1.2.0d13.x86_64pigsty434.2 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-cardano1.2.0d13.aarch64pigsty305.3 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-cardano1.2.0u22.x86_64pigsty483.1 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-cardano1.2.0u22.aarch64pigsty351.7 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-cardano1.2.0u24.x86_64pigsty478.2 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-cardano1.2.0u24.aarch64pigsty346.1 KiBpostgresql-18-pg-cardano_1.2.0-1PIGSTY~noble_arm64.deb
postgresql-18-pg-cardano1.2.0u26.aarch64pigsty333.6 KiBpostgresql-18-pg-cardano_1.2.0-2PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_cardano;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install pg_cardano;		# install via package name, for the active PG version

pig install pg_cardano -v 18;   # install for PG 18
pig install pg_cardano -v 17;   # install for PG 17
pig install pg_cardano -v 16;   # install for PG 16
pig install pg_cardano -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_cardano;

Usage

Sources: README, Cargo.toml version 1.2.0, releases page

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, but the current crate features and this repo’s package matrix target PostgreSQL 15 through 18, with pg18 as the default feature.
  • This repo packages pg_cardano 1.2.0 with pgrx 0.17.0 and the PG18 fix noted in extension.csv.
  • The simple CBOR helpers are intentionally lossy for some CBOR constructs; use the *_ext functions when exact structural round-tripping matters.
Last updated on