digitalsloth/znn-php
最新稳定版本:1.0.0
Composer 安装命令:
composer require digitalsloth/znn-php
包简介
A PHP SDK for JSON-RPC endpoints of the zenon.network
README 文档
README
The ZNN-PHP package allows you to read the JSON-RPC endpoints of the zenon.network as described here. It also provides methods for working with the ABI data.
- RPC Endpoints
- ABI Decoding
- ABI Encoding
- Wallet & Keyfile support
- Unit tests
Wallet and keyfile support is still a work in progress. PRs are welcome :)
Requirements
PHP 8.2 and later.
composer require digitalsloth/znn-php
Usage
RPC Setup
- Node Url - By default, it will try and connect to a local node
127.0.0.1:35997but you can pass in any public node URL. - Throw Errors - You can choose to throw errors or not, defaults to
false
Create a new instance of $znn calling the provider and method you want. All accelerator, pillar, plasma, sentinel, stake, swap , token, ledger and stats endpoints listed here can be reached through the $znn instance.
// config $nodeUrl = 'https://node.zenonhub.io:35997'; $throwErrors = true; // zenon client $znn = new \DigitalSloth\ZnnPhp\Zenon($nodeUrl, $throwErrors); // load all pillars $result = $znn->pillar->getAll(); if (! $result['status']) { die('Error loading data'); } echo $result['data']->count; foreach ($result['data']->list as $pillar) { var_dump($pillar); }
ABI Encoding/Decoding
Create a new instance of a $contract to access the encode and decode methods:
// pick a contract to work with $contract = new \DigitalSloth\ZnnPhp\Abi\Contracts\Accelerator(); $result = $contract->encode('CreateProject', ["Test", "Test", "Test.com", 1000000000, 10000000000]); $result = base64_encode($result); // d8BEtgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7msoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlQL5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFRlc3QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARUZXN0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIVGVzdC5jb20AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= $result = $contract->decode('CreateProject', base64_decode('d8BEtgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7msoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlQL5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFRlc3QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARUZXN0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIVGVzdC5jb20AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=')); var_dump($result); // ["Test","Test","Test.com","1000000000","10000000000"]
统计信息
- 总下载量: 2.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: mit
- 更新时间: 2022-06-14