mclever/larasui-sdk
Composer 安装命令:
composer require mclever/larasui-sdk
包简介
A Laravel SDK for interacting with the SUI blockchain.
README 文档
README
A comprehensive, Laravel-friendly SDK for interacting with the Sui blockchain using Move smart contracts. Built for developers to seamlessly integrate Sui’s features—token creation, NFT minting, staking, transaction batching, and more—into their Laravel applications.
Requirements
-
PHP: ^8.0
-
Laravel: ^10.0
-
Frontend wallet integration (e.g., @mysten/sui.js) for signing/executing transactions.
Table of Contents
Installation
Install the package via Composer:
composer require mclever/larasui-sdk
Publish the configuration file:
php artisan vendor:publish --tag="config"
This will create a sui.php configuration file in your config directory.
Configuration
Update the config/sui.php file with your SUI RPC URL:
return [ 'rpc_url' => env('SUI_RPC_URL', 'https://fullnode.devnet.sui.io:443'), ];
You can also set the SUI_RPC_URL in your .env file:
SUI_RPC_URL=https://fullnode.devnet.sui.io:443
Usage
Connecting to a Wallet
To connect to a wallet, use the connectWallet method. This method prepares the wallet connection, but the actual connection must be completed by the frontend (e.g., using @mysten/sui.js).
use Mclever\LarasuiSdk\Facades\Sui; $walletAddress = Sui::connectWallet();
Fetching Balances
Fetch the balance of an address for a specific coin type (default is SUI):
$balance = Sui::getBalance('0xYourAddress'); echo "Balance: {$balance} SUI";
Creating Tokens
Create a new fungible token:
$txDigest = Sui::createToken( 'MyToken', 'MTK', 6, // Decimals '0xYourAddress', 1000000, // Initial supply 10000 // Gas budget ); echo "Token creation transaction digest: {$txDigest}";
Creating NFTs
Create a new NFT:
$txDigest = Sui::createNFT( 'MyNFT', 'A unique NFT', 'https://example.com/nft-metadata.json', '0xYourAddress', 10000 // Gas budget ); echo "NFT creation transaction digest: {$txDigest}";
Executing Move Calls
Execute a Move call:
$txDigest = Sui::executeMoveCall( '0xPackageId', 'module_name', 'function_name', [], // Type arguments ['arg1', 'arg2'], // Function arguments '0xYourAddress', 10000 // Gas budget ); echo "Move call transaction digest: {$txDigest}";
Transferring Assets
Transfer coins or objects to another address:
$txDigest = Sui::transfer( '0xYourAddress', '0xRecipientAddress', '0xObjectId', 10000 // Gas budget ); echo "Transfer transaction digest: {$txDigest}";
Staking SUI
Stake SUI to a validator:
$txDigest = Sui::stakeSui( '0xYourAddress', '0xValidatorAddress', '0xCoinId', 1000000000, // Amount to stake 10000 // Gas budget ); echo "Staking transaction digest: {$txDigest}";
Fetching Transaction Details
Get details for a transaction by its digest:
$transaction = Sui::getTransaction('0xTransactionDigest'); print_r($transaction);
Fetching Events
Fetch recent events of a specific type:
$events = Sui::getEvents('0xPackage::module::Event', 10); print_r($events);
API Reference
SuiClient Methods
connectWallet(): Prepares wallet connection.getBalance(string $address, ?string $coinType = '0x2::sui::SUI'): Fetches the balance of an address.createToken(string $name, string $symbol, int $decimals, string $sender, int $initialSupply, int $gasBudget = 10000): Creates a new fungible token.createNFT(string $name, string $description, string $uri, string $sender, int $gasBudget = 10000): Creates a new NFT.executeMoveCall(string $packageId, string $module, string $function, array $typeArgs, array $args, string $sender, ?int $gasBudget = null): Executes a Move call.transfer(string $sender, string $recipient, string $objectId, int $gasBudget = 10000): Transfers coins or objects.stakeSui(string $sender, string $validatorAddress, string $coinId, int $amount, ?int $gasBudget = null): Stakes SUI to a validator.getTransaction(string $txDigest): Fetches transaction details.getEvents(string $eventType, int $limit = 10): Fetches recent events.getCoinMetadata(string $coinType): Fetches metadata for a coin type.
For a full list of methods, refer to the SuiClient class.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
Built by Mr clever with for the Sui and Laravel communities.
Support
For questions or issues, please open an issue on GitHub.
Happy coding! 🚀
mclever/larasui-sdk 适用场景与选型建议
mclever/larasui-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mclever/larasui-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mclever/larasui-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-27