Download the PHP package mrokwor/blockchain-sdk-php without Composer
On this page you can find all versions of the php package mrokwor/blockchain-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrokwor/blockchain-sdk-php
More information about mrokwor/blockchain-sdk-php
Files in mrokwor/blockchain-sdk-php
Package blockchain-sdk-php
Short Description High-performance, multi-chain PHP & Laravel SDK for Non-Custodial Wallet Generation, Transaction Signing, Resilient RPC Routing, and Automated Token Sweeping (EVM, Bitcoin, Solana, TRON).
License MIT
Informations about the package blockchain-sdk-php
Blockchain SDK for PHP
A high-performance, zero-third-party-cryptography blockchain SDK for PHP 8.2+ and Laravel (10, 11, 12, and 13). Generate multi-chain custodial/deposit addresses, validate addresses with EIP-55/Base58/Bech32 checksums, sign transactions locally and offline, estimate network fees, query token balances, auto-fuel gas to deposit sub-wallets, track deposits with database models, and sweep customer funds into master cold vaults across 17+ supported blockchains including EVM (Ethereum, BNB Smart Chain, Polygon, Arbitrum, Base, Optimism, Avalanche, Fantom, Cronos, Linea, Scroll, zkSync, Celo, Mantle), Solana, Bitcoin (Native SegWit Bech32), and TRON.
💡 Looking for working examples? Check out the official blockchain-sdk-php-examples repository for a complete runnable Laravel application featuring multi-chain wallet generation, deposit monitoring, transaction explorer discovery, and automated gas-sponsored token sweeps.
📚 Examples & Demo Application
We maintain a complete, ready-to-run demo application in the MrOkwor/blockchain-sdk-php-examples repository. It includes:
- Interactive Wallet Generator: Generate and inspect multi-chain keypairs across EVM, Solana, TRON, and Bitcoin.
- Address Validation Playground: Validate customer addresses with instant EIP-55, Base58, and Bech32 checksum verification.
- Live Deposit Monitoring: Real-time balance and incoming transaction detection across 17+ chains.
- Automated Gas Station Sweeper: Test end-to-end token sweeps with automatic native gas fueling on dry deposit addresses.
- Production Controllers & Blade Views: Copy-pasteable real-world Laravel controllers, models, and background artisan worker setups.
Features
- Zero External Cryptographic Dependencies: Pure-PHP mathematical primitives for Secp256k1 (with GMP acceleration), EVM Keccak-256 permutation, RFC-6979 deterministic nonce generation, Base58/Base58Check, and Bech32.
- 17+ Supported Blockchains & Standard Tokens: Pre-configured registry of supported token contracts, decimals, and enable/disable statuses for USDT, USDC, WBTC, DAI, LINK, UNI, and more.
- Multi-Chain Address Validation & Laravel Rules: Built-in address validation across all 17 chains (EVM 0x hex & EIP-55 checksums, Solana Base58 32-byte pubkeys, TRON Base58Check T-addresses with 0x41 prefix, Bitcoin Bech32/Base58) and ready-to-use Laravel
BlockchainAddressvalidation rule. - Separated Master Vaults & Hot Gas Station Architecture: Clean architectural separation between Master Cold Vault receiving destinations and Hot Gas Station fee dispensers. Modify your master receiving vaults anytime without touching or exposing your gas wallets.
- Automated Gas Station & Master Vault Generator: Generate master receiving vaults and hot gas station credentials in one command (
php artisan blockchainsdk:generate-master-wallets) with automated AES-256 encryption and formatted.envblocks. - Automated Gas Station & Fee Sponsorship: Solves the "empty gas tank" problem. Automatically detects if a customer sub-wallet has 0 native currency (0 BNB/TRX/ETH/SOL) and dispatches exact gas from a Master Hot Gas Wallet before executing the token sweep.
- Publishable Migrations & Eloquent Models: Publish customizable database schemas and models (
BlockchainSdkWallet,BlockchainSdkDeposit,BlockchainSdkSweep) directly intoapp/Models/. - Event-Driven Value Crediting: Dispatches lifecycle events (
DepositConfirmed,WalletSwept) to give balance value to users immediately upon deposit confirmation or after vault consolidation. - Multi-Node Failover RPC Client: Built-in round-robin health-checking and automatic failover across multiple fallback RPC endpoints.
- Automated Vault Sweeper: Compute network fees and automatically sweep funds from customer deposit addresses into master cold vaults.
- Full Laravel 10, 11, 12, and 13 Support: First-class Service Provider, Facade (
Blockchain::driver(...)), publishableconfig/blockchainsdk.php, and ready-to-use Artisan commands (blockchainsdk:generate-master-wallets,blockchainsdk:sweep,blockchainsdk:monitor). - Offline & Secure Signing: Private keys never leave your application server; transactions are constructed and signed locally before raw broadcast.
Supported Networks & Driver Identifiers
The SDK supports 17 individual network drivers out of the box:
| Driver Code | Network Name | Ecosystem | Address Format | Signing Algorithm |
|---|---|---|---|---|
ethereum |
Ethereum Mainnet | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
bsc |
BNB Smart Chain | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
polygon |
Polygon POS | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
arbitrum |
Arbitrum One | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
optimism |
OP Mainnet | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
base |
Base | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
avalanche |
Avalanche C-Chain | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
fantom |
Fantom Opera | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
cronos |
Cronos Chain | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
linea |
Linea | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
scroll |
Scroll | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
zksync |
zkSync Era | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
celo |
Celo | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
mantle |
Mantle | EVM | EIP-55 Hex (0x...) |
Secp256k1 + EIP-155 / RLP |
solana |
Solana | Solana | Base58 Public Key | Ed25519 (Libsodium) |
tron |
TRON | TRON | Base58Check (T...) |
Secp256k1 + SHA-256 |
bitcoin |
Bitcoin | UTXO | Native SegWit Bech32 (bc1q...) |
Secp256k1 + BIP-143 |
Requirements
- PHP 8.2+
- Extensions:
ext-gmp(Required for Secp256k1 elliptic curve point arithmetic)ext-sodium(Required for Solana Ed25519 signatures; enabled by default in PHP 7.2+)ext-bcmath(Required for arbitrary-precision wei / satoshi math)ext-curl&ext-json
Installation
Install the package via Composer:
Part 1: Laravel Integration Guide (Laravel 10, 11, 12, and 13)
If you are using Laravel, the package registers automatically via auto-discovery.
1. Publishing Assets
A. Publish Configuration File (config/blockchainsdk.php)
B. Publish Database Migrations
C. Publish Eloquent Models to app/Models/
D. Run Migrations
2. Generating Master Vaults & Hot Gas Wallets
To sweep customer deposits into a central vault or sponsor network fees for dry sub-wallets, your platform needs Master Cold Vault Receiving Addresses and Hot Gas Station credentials.
You can generate both in a single command with automatic AES-256 encryption and clean, separated .env blocks:
How Master & Gas Wallets Are Stored in .env
[!TIP] Independent Separation: You can change your
BLOCKCHAIN_MASTER_*destination addresses anytime (e.g. directing funds to a Hardware Ledger or Gnosis Safe multisig) without affecting or resetting yourBLOCKCHAIN_GAS_*fee sponsor keys.
3. Validating Wallet Addresses in Laravel
You can validate customer receiving/payout addresses using the Blockchain::validateAddress() facade or the built-in Laravel Validation Rule:
Option A: Using the BlockchainAddress Validation Rule in Form Requests / Controllers
Option B: Validating Directly via Facade
4. Generating Multi-Chain Deposit Wallets in Laravel
Option A: Using Eloquent Models (Recommended)
Automatically creates a wallet keypair, encrypts the private key, and associates it with a user in your database:
Option B: Using the Blockchain Facade Directly
5. Querying Balances & Checking Token Statuses in Laravel
5.5 Discovering Incoming Deposit Transaction Hashes
When customers deposit funds into temporary sub-wallets or personal addresses, you can automatically capture the incoming blockchain transaction hash across EVM, Solana, TRON, and Bitcoin without writing low-level RPC chunking loops:
6. Sweeping Sub-Wallets into Master Vaults in Laravel
A. Sweeping Native Currency via Facade
B. Sweeping Supported Tokens via Facade
C. Sweeping Dry Wallets with Automated Gas Sponsorship
7. Giving Value to Users After Sweeping or Depositing in Laravel
In crypto platforms and fintech applications, "giving value" means crediting the customer's account balance, ledger, or wallet in your application database. The SDK dispatches events so you can execute your own custom credit logic.
Paradigm A: Credit After Master Vault Sweep (Post-Sweep Hook)
-
Execute the sweep command with the
--creditflag: - Listen to
BlockchainSdk\Laravel\Events\WalletSweptin your application:
Paradigm B: Immediate Credit on Confirmed Deposit (Instant UX)
If you want users to receive their platform balance as soon as the transaction is confirmed on-chain (while vault sweeping runs asynchronously in the background):
8. Laravel Artisan Commands Reference
| Command | Description | Options |
|---|---|---|
php artisan blockchainsdk:generate-master-wallets |
Generates master cold vault receiving addresses and hot gas station credentials in separated .env blocks |
--network=, --no-encrypt, --no-store, --force |
php artisan blockchainsdk:sweep |
Sweeps sub-wallets into central cold vault | --network=, --token= (symbol/contract), --sponsor (auto-gas), --credit (dispatch value event) |
php artisan blockchainsdk:monitor |
Multi-chain background deposit confirmation listener | --network=, --token=, --once (run single pass) |
php artisan vendor:publish --tag="blockchainsdk-config" |
Publishes config/blockchainsdk.php |
--force (overwrite existing) |
php artisan vendor:publish --tag="blockchainsdk-migrations" |
Publishes database migrations | --force (overwrite existing) |
php artisan vendor:publish --tag="blockchainsdk-models" |
Publishes Eloquent models to app/Models/ |
--force (overwrite existing) |
Part 2: Standalone / Vanilla PHP Guide (Non-Laravel)
You can use blockchain-sdk-php in any PHP application, microservice, or framework (Symfony, Slim, Laminas, WordPress, pure PHP CLI scripts) without Laravel.
1. Initialization
Instantiate the BlockchainManager with a configuration array:
2. Validating Addresses in Vanilla PHP
3. Generating Wallets in Vanilla PHP
4. Querying Balances & Checking Tokens in Vanilla PHP
5. Sweeping Sub-Wallets & Sponsoring Gas in Vanilla PHP
Part 3: Architecture & Security
Adding Custom Tokens
You can register new custom or standard ERC-20, SPL, or TRC-20 tokens on any blockchain by adding them to the tokens array:
Testing
Run the package test suite with PHPUnit:
Security Best Practices
- Keep Private Keys Encrypted at Rest: Always store custodial keys using strong symmetric encryption (e.g.
AES-256-GCM/ Laravel'sCrypt::encryptStringorcasts => ['private_key' => 'encrypted']). - Separate Cold Master Vaults from Hot Gas Stations: Keep your main reserves in cold storage (
master_wallets), while maintaining small working balances in hot gas station wallets (master_gas_wallets) solely for gas fueling. - Never Pass Private Keys over RPC: All signing in this library happens locally on your application server. The RPC nodes only receive the final, cryptographically signed raw byte payload.
- Use Dedicated RPC Nodes in Production: While public RPCs are supported, running dedicated nodes (e.g. QuickNode, Alchemy, Helius, Trongrid) provides higher throughput and zero rate-limiting.
License
The MIT License (MIT). Please see License File for more information.
All versions of blockchain-sdk-php with dependencies
ext-gmp Version *
ext-sodium Version *
ext-bcmath Version *
ext-json Version *
guzzlehttp/guzzle Version ^7.0 || ^8.0