overlay/overlay-php
Composer 安装命令:
composer require overlay/overlay-php
包简介
Overlay enables simple Web3 development across multiple blockchains, including Solana, Ethereum, BSC, Base, Polygon, and Bera. It does not require signing transactions with wallets, which is typically necessary in blockchain development.
README 文档
README
A PHP library for Web3 development that makes it easy to implement wallet creation, token and NFT issuance, minting, burning, and transfers across multiple blockchains.
📖 Overview
Overlay enables simple Web3 development across multiple blockchains, including:
- Solana
- Ethereum
- BSC (Binance Smart Chain)
- Base
- Polygon
- Bera Chain
It eliminates the need for signing transactions with wallets, which is typically necessary in blockchain development. Overlay implements high-level security features and securely encrypts wallet information to safely execute transactions without storing any database locally.
🚀 Installation
Via Composer
composer require overlay/overlay-php
⚙️ Configuration
Before using the library, you need to configure your API credentials:
<?php require_once 'vendor/autoload.php'; use Overlay\Client; $client = new Client([ 'api_key' => 'your_api_key', 'auth_key' => 'your_auth_key', 'env' => 'devnet' // or 'mainnet' ]);
🌐 Environment Options
| Environment | URL | Description |
|---|---|---|
devnet |
https://devnet.overlay.fun |
Development environment |
mainnet |
https://mainnet.overlay.fun |
Production environment |
📘 Usage
👛 Wallet
Create a Wallet
// Create a new wallet $response = $client->wallet->create([ 'network' => 'solana' // or 'evm' ]); echo $response;
🪙 Token
Create a Token
// Create a new token $response = $client->token->create([ 'network' => 'solana', // or 'eth', 'base', 'bsc', 'blast', 'polygon', 'bera', 'monad', etc 'name' => 'My Token', 'symbol' => 'MTK', 'image' => 'image url', 'supply' => 1000000000, 'decimals' => 9, // Add other token parameters ]); echo $response;
Mint Tokens
// Mint tokens to an address $mintAddress = 'your_token_mint_address'; $response = $client->token->mint($mintAddress, [ 'network' => 'solana', 'amount' => 1000 ]); echo $response->success;
Transfer Tokens
// Transfer tokens between addresses $response = $client->token->transfer($mintAddress, [ 'network' => 'solana', 'amount' => 1000, 'recipient' => 'recipient_address' ]);
Burn Tokens
// Burn tokens $response = $client->token->burn($mintAddress, [ 'network' => 'solana', 'amount' => 1000 ]);
🖼️ NFT
Create an NFT
// Create a new NFT collection or individual NFT $response = $client->nft->create([ 'network' => 'solana', 'name' => 'My NFT', 'symbol' => 'MNFT', 'description' => 'A unique NFT', 'images' => ['https://example.com/image.png'], // Add other NFT metadata ]); echo $response->success;
Mint NFTs
// Mint an NFT $mintAddress = 'your_nft_mint_address'; $response = $client->nft->mint($mintAddress, [ 'network' => 'solana' ]);
Transfer NFTs
// Transfer an NFT $response = $client->nft->transfer($mintAddress, [ 'network' => 'solana', 'recipient' => 'new_owner' ]);
Burn NFTs
// Burn an NFT $response = $client->nft->burn($mintAddress, [ 'network' => 'solana' ]);
📦 Response Object
All methods return an Overlay\Response object with the following structure:
$response = $client->token->create($params); // Access response properties echo $response->success; // Boolean indicating success/failure echo $response->message; // Response message print_r($response->data); // Response data array // Data properties are also accessible directly echo $response->mint_address ?? 'N/A'; // Direct access to data properties // Convert to array or JSON $array = $response->toArray(); $json = $response->toJson();
⚠️ Error Handling
The library includes built-in error handling. Always check the success property of the response:
$response = $client->token->mint($mintAddress, ['amount' => 1000]); if ($response->success) { echo "✅ Token minted successfully!\n"; echo "Transaction ID: " . $response->transaction_id . "\n"; } else { echo "❌ Error: " . $response->message . "\n"; }
🌍 Supported Blockchains
- 🔥 Solana
- ⚡ Ethereum
- 💛 Binance Smart Chain (BSC)
- 🔵 Base
- 🟣 Polygon
- 🐻 Bera Chain
🔐 Security Features
- ✅ No local database storage
- 🔒 Secure wallet encryption
- 🛡️ High-level security implementation
- 🔑 Safe transaction execution without exposing private keys
📋 Requirements
- PHP >= 8.0
- ext-curl - cURL extension
- ext-json - JSON extension
🛠️ Development
After cloning the repository, run:
composer install
Running Tests
# Run PHPUnit tests (when available) composer test
🤝 Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/overlaydotfun/overlay-php.
📚 Documentation
For more detailed documentation, visit: https://docs.overlay.fun
📄 License
This library is available as open source under the terms of the MIT License.
📞 Contact
- 📧 Email: contact@overlay.fun
- 🌐 Website: https://overlay.fun
- 📖 Documentation: https://docs.overlay.fun
Examples
Complete Example
<?php require_once 'vendor/autoload.php'; use Overlay\Client; // Initialize client $client = new Client([ 'api_key' => 'your_api_key', 'auth_key' => 'your_auth_key', 'env' => 'devnet' ]); try { // Create a wallet $walletResponse = $client->wallet->create(['network' => 'solana']); if ($walletResponse->success) { echo "Wallet created: " . $walletResponse->wallet_address . "\n"; } // Create a token $tokenResponse = $client->token->create([ 'network' => 'solana', 'name' => 'Test Token', 'symbol' => 'TEST', 'supply' => 1000000, 'decimals' => 9 ]); if ($tokenResponse->success) { echo "Token created: " . $tokenResponse->mint_address . "\n"; // Mint some tokens $mintResponse = $client->token->mint($tokenResponse->mint_address, [ 'network' => 'solana', 'amount' => 1000 ]); if ($mintResponse->success) { echo "Tokens minted successfully!\n"; } } } catch (Exception $e) { echo "Error: " . $e->getMessage() . "\n"; }
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-18