Download the PHP package kadena-php/client without Composer

On this page you can find all versions of the php package kadena-php/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package client

Kadena PHP Client

Latest Version on Packagist Total Downloads

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

Via Composer

Usage

Key Pairs

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

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:

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

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

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:

Multiple signers can be wrapped in the SignerCollection object.

Payloads

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

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:

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

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.

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

This returns a new instance of a SignedCommand

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:

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

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:

The client has a few methods available, see the Pact API docs for more information on the different use-cases and expected responses.

local

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

send

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

listen

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

poll

Takes a RequestKeyCollection as a parameter and returns a ResponseInterface.

spv

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

Change log

Please see the changelog for more information on what has changed recently.

Testing

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security-related issues, please send an email instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of client with dependencies

PHP Build Version
Package Version
Requires ext-sodium Version *
paragonie/halite Version ^5.1
symfony/http-client Version ^6.2
nesbot/carbon Version ^2.64
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kadena-php/client contains the following files

Loading the files please wait ....