make-software/casper-php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

make-software/casper-php-sdk

最新稳定版本:1.4.1

Composer 安装命令:

composer require make-software/casper-php-sdk

包简介

PHP 7.4+ library for interacting with Casper blockchain node RPC API.

README 文档

README

The PHP SDK allows developers to interact with the Casper Network using PHP. This page covers different examples of using the SDK.

Install

composer require make-software/casper-php-sdk

Usage

Creating RpcClient

Create RpcClient by passing node url and headers (optional) to constructor

$nodeUrl = 'http://127.0.0.1:7777';
$headers = array('Authorization' => 'Bearer 6ae6c8b31f09df244019ffef60c274e4'); // Optional

$client = new Casper\Rpc\RpcClient($nodeUrl, $headers);

RPC call examples

You can find all RpcClient methods on the RpcClientAPI page. Here you can see a several of examples of using RpcClient. All examples below are supposed to be ran against the Testnet

Get deploy by deploy hash

$deploy = $client->getDeploy('fa815fc43c38da30f6ab4e5a6c8a1b31f09df2bf4b344019ffef60c1270d4e49');

$deployHeader = $deploy->getHeader();
$creationTime = $deployHeader->getTimestamp();

Get auction state information

$auctionState = $client->getAuctionState();

$stateRootHash = $auctionState->getStateRootHash();
$blockHeight = $auctionState->getBlockHeight();

Get peers from the network

$peers = $client->getPeers();

foreach ($peers as $peer) {
    ...
}

Get the latest block information

$latestBlock = $client->getLatestBlock();
$latestBlockHash = $latestBlock->getHash();

More examples

API

RpcClient

DeployService

ContractService

Entities

Testing

Run the following command from the project directory.

Replace http://127.0.0.1:7777 by the any Testnet node url before running

export CASPER_PHP_SDK_TEST_NODE_URL="http://127.0.0.1:7777" && php vendor/bin/phpunit tests

统计信息

  • 总下载量: 1.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 7
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-09-22