PHP-Cardano

Pure PHP Cardano wallet generation and transaction signing. Zero dependencies, triple-fallback Ed25519 crypto, CIP-1852 compliant.

PHP-Cardano is a pure PHP implementation of Cardano wallet generation and transaction signing, purpose-built for environments where installing external binaries is not an option. If you run WordPress on shared hosting, manage a PHP-based application without root access, or simply want a self-contained Cardano integration that works out of the box, this library delivers exactly that — with zero external dependencies.

At its core, PHP-Cardano implements the full cryptographic pipeline required by the Cardano blockchain: BIP39 mnemonic generation and restoration (12–24 word phrases), CIP-1852 hierarchical deterministic wallet derivation, Icarus root key generation via PBKDF2-HMAC-SHA512, and Ed25519-BIP32 child key derivation following the Khovratovich/Law specification. Addresses are encoded in Bech32 for both mainnet and preprod networks. Transaction signing uses Cardano’s no-clamp Ed25519 extended key scheme, with a format-agnostic CBOR codec that handles simple payments, metadata, NFT mints, multi-asset transfers, staking operations, and policy key signing without needing to interpret the transaction body.

What sets this library apart is its triple-fallback cryptographic architecture. It automatically selects the fastest available backend: native PHP Sodium for near-instant wallet generation, FFI bindings to libsodium for solid mid-range performance, or a pure PHP BCMath implementation that runs on virtually any hosting environment. This means your WordPress blockchain integration works whether you are on a high-performance VPS or a basic shared hosting plan — no server configuration required.

PHP-Cardano is currently in beta and works as a standalone PHP library or as a WordPress plugin with an admin interface for wallet management, transaction building, and submission via the Ada Anvil API. It is ideal for developers building Cardano-powered WordPress sites, payment gateways, token-gated content systems, or any PHP application that needs native wallet and transaction capabilities without shelling out to external tools.

Trust Model

Hybrid Non-custodial

This plugin uses a hybrid custody model. The server holds an encrypted policy wallet for co-signing, while the user’s browser wallet provides the second signature. Neither party can act alone.

Installation

Install Steps
1. Download the ZIP from the Download button above
2. Upload to your WordPress plugins directory: wp-content/plugins/
3. Activate via Plugins > Installed Plugins
4. See the README for configuration and usage examples

Documentation

PHP Cardano

Pure PHP implementation of Cardano wallet generation and transaction signing with zero external dependencies.

Generate wallets, derive keys, and sign transactions using only PHP native extensions - no Python, no Node.js, no external binaries required.


โš ๏ธ Beta Status

This library is currently in BETA. While the core cryptographic implementations have been extensively tested and follow Cardano standards (CIP-1852, Ed25519-BIP32, Icarus derivation), the following would be valuable:

  • Community testing across different PHP environments and versions
  • Feedback on API design and developer experience
  • Bug reports and edge case discoveries
  • Code review from cryptography and Cardano experts
  • Performance benchmarks on various hosting configurations

Use with caution in production. Always test with small amounts on preprod/testnet first.

๐Ÿ‘‰ Found an issue or want to contribute? Open an issue on GitHub for any feedback!


Key Features

  • โœ… CIP-1852 compliant HD wallet derivation (m/1852'/1815'/0'/0/0)
  • โœ… Icarus root key generation using PBKDF2-HMAC-SHA512 with correct clamping
  • โœ… Ed25519-BIP32 (Khovratovich/Law) child key derivation
  • โœ… Extended key signing (kL||kR) for proper Cardano transaction signatures
  • โœ… Pure PHP CBOR codec for encoding/decoding transaction structures
  • โœ… Format-agnostic signer - works with payments, metadata, NFT mints, multi-asset transfers, staking
  • โœ… Multi-signature ready - generates witness sets that merge with other signers
  • โœ… No external dependencies - uses only PHP built-in extensions
  • โœ… Multi-layer fallback system: native sodium โ†’ FFI โ†’ pure PHP (BCMath)
  • โœ… BIP39 mnemonic generation and restoration (12-24 words)
  • โœ… Bech32 address encoding for mainnet and testnet addresses
  • โœ… WordPress plugin integration with admin interface and Anvil API support

Architecture Overview

Core Components

Component Purpose
CardanoWalletPHP.php Wallet generation, BIP39 mnemonic handling, CIP-1852 key derivation, address generation
CardanoTransactionSignerPHP.php Transaction signing, CBOR encoding/decoding, witness set construction
Ed25519Compat.php Ed25519 compatibility layer with triple-fallback (native/FFI/pure)
Ed25519Pure.php Pure PHP Ed25519 implementation using BCMath (fallback)
bip39-wordlist.php BIP39 English wordlist (2048 words)
cardano-wallet-test.php WordPress plugin integration with admin UI

Frequently Asked Questions

Does PHP-Cardano require any PHP extensions?
No. It uses a triple-fallback crypto strategy: native sodium extension, FFI bindings, or pure PHP implementation. It works on any PHP 7.4+ host.
Can I use this for mainnet transactions?
Yes. PHP-Cardano supports both testnet and mainnet. Always test on preprod/preview testnets first.
How does wallet generation work?
It generates BIP39 mnemonics, derives Icarus root keys with proper clamping, and supports CIP-1852 derivation paths for spending, staking, and change keys.