Skip to content

MultiversX SDK for Laravel (written in PHP).

License

Notifications You must be signed in to change notification settings

PeerMeHQ/mx-sdk-laravel

Repository files navigation

MultiversX SDK for Laravel

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This SDK is a wrapper around the native mx-sdk-php to enable out-of-the-box support for Laravel applications.

Additionally, it comes with pre-configured MultiversX API Network Providers including caching mechanisms using the default Laravel cache driver.

Installation

You can install the package via composer:

composer require peerme/mx-sdk-laravel

And publish the config file config/multiversx.php via

php artisan vendor:publish --provider="MultiversX\ServiceProvider" --tag="config"

Usage

Since this package wraps & configures the native packages for Laravel, you can access their utitlies without further configurations.

This includes:

  • User Login Signature Verification
  • MultiversX constants
  • Domain Objects
  • Blockchain-specific constants
  • Other Utitilies & more

For more details, please refer to their documentation:

Calling the API

When instantiating the Network Providers, you can decide to optionally cache responses:

use MultiversX\Multiversx;

// retrieve fresh responses each time
$api = Multiversx::api();

// or retrieve cached responses subsequently for 1 hour
$api = Multiversx::apiWithCache(expiresAt: now()->addHour());

Validation Rules

This package exposes the following Laravel Validation Rules.

MxAddressRule – to validate a given address format:

[
    'address' => ['required', new MxAddressRule],
]

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.