pg_cardano
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_cardano | 1.2.0 | FEAT | MIT | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2920 | pg_cardano | No | Yes | No | Yes | No | No | - |
| Related | age hll rum pg_graphql pg_jsonschema jsquery pg_hint_plan hypopg |
|---|
PG18 fix by https://github.com/Vonng/pg_cardano
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.2.0 | 1817161514 | pg_cardano | - |
| RPM | PIGSTY | 1.2.0 | 1817161514 | pg_cardano_$v | - |
| DEB | PIGSTY | 1.2.0 | 1817161514 | postgresql-$v-pg-cardano | - |
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, withpg18as the default feature. - The simple CBOR helpers are intentionally lossy for some CBOR constructs; use the
*_extfunctions when exact structural round-tripping matters.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.