PHPackages                             kadena-php/client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kadena-php/client

ActiveLibrary[API Development](/categories/api)

kadena-php/client
=================

PHP Client for use with the Kadena Pact API

v0.1.1(3y ago)3441MITPHP

Since Jan 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kadena-php/client)[ Packagist](https://packagist.org/packages/kadena-php/client)[ Docs](https://github.com/kadena-php/client)[ RSS](/packages/kadena-php-client/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (6)Versions (8)Used By (1)

Kadena PHP Client
=================

[](#kadena-php-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dcfa5f08169405dca6e69b40bb24a8df1a8430e06ff02f870c0d04a7c29be04a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6164656e612d7068702f636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kadena-php/client)[![Total Downloads](https://camo.githubusercontent.com/9b572d7413cebc1268a1f3e24723d49c034daf055ae58f6a31d1cc572485aa11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6164656e612d7068702f636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kadena-php/client)

This package includes a simple-to-use client to communicate with the Pact API, as well as classes to generate keys, prepare and create Pact commands and the ability to sign commands in your backend.

Using this package allows you to call things like admin functions in Pact from your PHP backend by creating and signing commands, but it also allows you to create a command in the backend, have a wallet sign it on the frontend, and then call the Pact API in the backend.

> If your users have to sign a command, something like Kadena.js would still be required on the frontend. This is not a complete replacement.

> ⚠️ This package is under active development and has no stable production release yet

Installation
------------

[](#installation)

Via Composer

```
composer require kadena-php/client
```

Usage
-----

[](#usage)

### Key Pairs

[](#key-pairs)

Key Pairs are used to sign your Pact commands. You can generate a new KeyPair using

```
$keyPair = KeyFactory::generate();
```

### Metadata

[](#metadata)

Every command sent to the Kadena API requires a metadata object to be present. This object can be created manually, or be constructed using the `MetadataFactory`. The factory will set predefined defaults if certain options are no provided. The defaults and options are as follows:

```
creationTime: Carbon::now(),
ttl: 7200,
gasLimit: 10000,
chainId: '0',
gasPrice: 1e-8,
sender: ''
```

If we want to create an object with the default options but on a different chain, we can do it like this:

```
$factory = new MetadataFactory();
$metadata = $factory->withOptions([
    'chainId' => '1',
])->make();
```

If no custom options are required, you can just call `$factory->make()` to create your `Metadata` object.

### Signers

[](#signers)

Commands have to be signed before sending them to the Kadena API. To support this, a `Signer` (one or many) has to be created. A signer consists of a public key and optionally a list of capabilities.

Let's create a signer with a public key of `example-key` and the `coin.transfer` capability. As a signer can have multiple or no capabilities, all `Capability` objects should be wrapped in a `CapabilityCollection` object:

```
$publicKey = KeyFactory::publicKeyFromHex('not-a-real-key');

$transferCapability = new Capability(
    name: 'coin.transfer',
    arguments: [
        'address-from',
        'address-to',
        5
    ]
);

$signer = new Signer(
    publicKey: $publicKey,
    capabilities: new CapabilityCollection($transferCapability)
)
```

Multiple signers can be wrapped in the `SignerCollection` object.

### Payloads

[](#payloads)

Payloads are the code to be executed by pact. There are two types of payloads: and execute and a continue payload.

```
$executePayload new ExecutePayload(
    code: '(+ 1 2)'
);

$continuePayload =  new ContinuePayload(
    pactId: 'pact-id',
    rollback: false,
    step: 0
);
```

### Commands

[](#commands)

Commands wrap all data sent to the Kadena API, a `Command` object can be created manually, but it is recommended to use the `CommandFactory` for this. The factory will set certain defaults, and can be used like this:

```
$factory = new CommandFactory();

$factory->withExecutePayload($executePayload)
    ->withMetadata($metadata)
    ->withSigners(new SignerCollection($signer))
    ->withNetworkId('mainnet0')
    ->withNonce('nonce-string')
    ->make();
```

The `withExecutePayload` or the `withContinuePayload` options are always required to create a `Command` object, but all others are optional.

### Signing Commands

[](#signing-commands)

After creating a command, you can sign it using any number of key pairs. To do this, first, create a `KeyPairCollection` from the key pairs you have. These key pairs should correspond to the signers you added to your account.

```
$kpc = new KeyPairCollection($keypair);
```

Now using these key pairs, we can sign the previously created command

```
$signedCommand = CommandSigner::sign($command, $kpc);
```

This returns a new instance of a `SignedCommand`

### Constructing commands from a string

[](#constructing-commands-from-a-string)

Instead of signing the command in the backend, a command might be signed elsewhere (user wallet). A signed command can be reconstructed from a valid Pact command string using:

```
$signedCommand = SignedCommandMapper::fromString($commandString)
```

A signed command can also be cast to a string or an array using

```
$commandString = SignedCommandMapper::toString($signedCommand);
$commandArray = SignedCommandMapper::toArray($signedCommand);
```

### Using the Client

[](#using-the-client)

Now we have figured out how to create commands and sign them, it's time to use them to make calls to the Pact API.

First, create a new API client:

```
$client = new \Kadena\Client('http://localhost:8888'); // or whatever local config you have
```

The client has a few methods available, see the [Pact API docs](https://api.chainweb.com/openapi/pact.html#tag/endpoint-local) for more information on the different use-cases and expected responses.

#### local

[](#local)

Takes a single `SignedCommand` as a parameter and returns a `ResponseInterface`.

```
$local = $client->local($signedCommand);
```

#### send

[](#send)

Takes a multiple `SignedCommand` wrapped in a `SignedCommandCollection` as a parameter and returns a `RequestKeyCollection`.

```
$send = $client->send(new SignedCommandCollection($signedCommand));
```

#### listen

[](#listen)

Takes a single `RequestKey` as a parameter and returns a `ResponseInterface`.

```
$requestKey = $send->first(); // Get a RequestKey from the send response above
$listen = $client->single($requestKey);
```

#### poll

[](#poll)

Takes a `RequestKeyCollection` as a parameter and returns a `ResponseInterface`.

```
$requestKeyCollection = $send; // The send() method above returned a RequestKeyCollection
$poll = $client->poll($requestKeyCollection);
```

#### spv

[](#spv)

Takes a `RequestKey` and a `string $targetChainId` as parameters and returns a `string`.

```
$spv = $client->spv($requestKey, '2');
```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security-related issues, please send an [email](mailto:hergen.dillema@gmail.com) instead of using the issue tracker.

Credits
-------

[](#credits)

- [Hergen Dillema](https://github.com/hergend)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

1270d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/66e3e5ddb7ac36dd1858b7ca40280233c9ecf05b5d0040353af7308c6f482259?d=identicon)[HergenD](/maintainers/HergenD)

---

Top Contributors

[![HergenD](https://avatars.githubusercontent.com/u/32772820?v=4)](https://github.com/HergenD "HergenD (6 commits)")

---

Tags

kadenakdapactphpphp8phpKadena

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/kadena-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/kadena-php-client/health.svg)](https://phpackages.com/packages/kadena-php-client)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[temporal/sdk

Temporal SDK

4072.9M25](/packages/temporal-sdk)[bitrix24/b24phpsdk

An official PHP library for the Bitrix24 REST API

10244.2k5](/packages/bitrix24-b24phpsdk)[storyblok/php-management-api-client

Storyblok PHP Client for Management API

1233.5k3](/packages/storyblok-php-management-api-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
