multiplechain/solana-sdk
Composer 安装命令:
composer require multiplechain/solana-sdk
包简介
Solana PHP SDK
README 文档
README
NOTE: This package has been forked to be developed at MultipleChain to provide infrastructure for Solana. We are not adding it internally to MultipleChain because MultipleChain is an interface that covers all Blockchain networks. But for those who just want to do something for Solana, we aim to make something that covers everything in Solana/Web3.js.
Forked from: Sellix/solana-php-sdk
Simple PHP SDK for Solana.
Installation
You can install the package via composer:
composer require multiplechain/solana-sdk
Usage
Using the Solana simple client
You can use the Connection class for convenient access to API methods. Some are defined in the code:
use MultipleChain\SolanaSDK\Connection; use MultipleChain\SolanaSDK\SolanaRpcClient; // Using a defined method $sdk = new Connection(new SolanaRpcClient(SolanaRpcClient::MAINNET_ENDPOINT)); $accountInfo = $sdk->getAccountInfo('4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA'); var_dump($accountInfo);
For all the possible methods, see the API documentation.
Directly using the RPC client
The Connection class is just a light convenience layer on top of the RPC client. You can, if you want, use the client directly, which allows you to work with the full Response object:
use MultipleChain\SolanaSDK\SolanaRpcClient; $client = new SolanaRpcClient(SolanaRpcClient::MAINNET_ENDPOINT); $accountInfoResponse = $client->call('getAccountInfo', ['4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA']); $accountInfoBody = $accountInfoResponse->json(); $accountInfoStatusCode = $accountInfoResponse->getStatusCode();
Transactions
Here is working example of sending a transfer instruction to the Solana blockchain:
$client = new SolanaRpcClient(SolanaRpcClient::DEVNET_ENDPOINT); $connection = new Connection($client); $fromPublicKey = KeyPair::fromSecretKey([...]); $toPublicKey = new PublicKey('J3dxNj7nDRRqRRXuEMynDG57DkZK4jYRuv3Garmb1i99'); $instruction = SystemProgram::transfer( $fromPublicKey->getPublicKey(), $toPublicKey, 6 ); $transaction = new Transaction(null, null, $fromPublicKey->getPublicKey()); $transaction->add($instruction); $txHash = $connection->sendTransaction($transaction, $fromPublicKey);
Note: This project is in alpha, the code to generate instructions is still being worked on $instruction = SystemProgram::abc()
Roadmap
- Borsh serialize and deserialize.
- Improved documentation.
- Build out more of the Connection, SystemProgram, TokenProgram, MetaplexProgram classes.
- Improve abstractions around working with binary data.
- Optimizations:
- Leverage PHP more.
- Better cache
$recentBlockhashwhen sending transactions.
- Suggestions? Open an issue or PR :D
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please create an issue in this repository.
Credits
- Matt Stauffer (Original creator)
- Zach Vander Velden (Metadata wizard)
- Halil Beycan (Maintainer)
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
multiplechain/solana-sdk 适用场景与选型建议
multiplechain/solana-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 06 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「sdk」 「blockchain」 「sol」 「solana-php-sdk」 「solana」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 multiplechain/solana-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 multiplechain/solana-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 multiplechain/solana-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Solana PHP SDK for interacting with the Solana blockchain
A fast and dynamic Merkle tree implementation
Multichain JSON-RPC Client
Alfabank REST API integration
Implementation of Bitclout API interaction through its node
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 24
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-05