kadena-php/laravel

Laravel Client for use with the Kadena Pact API

v0.1.0 2023-01-09 14:46 UTC

This package is auto-updated.

Last update: 2024-12-09 20:34:16 UTC


README

Latest Version on Packagist Total Downloads

This package includes a simple-to-use client to communicate with the Pact API.

Note: This repository only contains the integration code of the Kadena PHP client for Laravel. If you want to use the Kadena PHP client in a framework-agnostic way, take a look at the kadena-php/client repository.

Installation

Via Composer

composer require kadena-php/laravel

You can configure the Kadena API base URL by configuring your env:

KADENA_API_BASE_URL=http://localhost:8000

Optionally, you can also publish the config file:

php artisan vendor:publish --tag=kadena-config

Usage

For usage examples, see the kadena-php/client repository before starting to use the Laravel integration.

This package contains three convenience Facades. Their usage are largely similar to the classes documented in the client package:

Client Facade

Kadena\Laravel\Facades\Client

Usage

$response = Client::local($signedCommand);

Command Facade

Kadena\Laravel\Facades\Command

Usage

$command = Command::withExecutePayload($payload)
    ->withMetadata($metadata)
    ->make();

To see all options, see the Command Factory documentation in the client repository.

Metadata Facade

Kadena\Laravel\Facades\Metadata

Usage

$metadata = Metadata::make();

To see all options, see the Metadata Factory documentation in the client repository. When not specifying any options like the example above, the options set in the kadena.php config will be used.

Config

An example of the default config:

return [
    'api' => [
        'base_url' => env('KADENA_API_BASE_URL', 'http://localhost:8888'),
    ],
    'meta' => [
        'ttl' => 7200,
        'gasLimit' => 10000,
        'chainId' => '0',
        'gasPrice' => 1e-8,
        'sender' => ''
    ],
];

Change log

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

Testing

./vendor/bin/phpunit

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.