php-core/wert-sc-signer

PHP library for SmartContracts Wert's requests signing simplification

1.0.0 2025-08-06 11:27 UTC

This package is auto-updated.

Last update: 2025-08-06 11:28:51 UTC


README

Installation

composer require php-core/wert-sc-signer

Usage

Standard PHP

use PHPCore\WertScSigner\WertScSigner;

$signedData = WertScSigner::signSmartContractData($options, $privateKey);

Laravel

The package includes Laravel integration. The service provider and facade will be automatically registered.

  1. Publish the configuration file:
php artisan vendor:publish --provider="PHPCore\WertScSigner\Laravel\WertScSignerServiceProvider" --tag="config"
  1. Add your Wert private key to your .env file:
WERT_PRIVATE_KEY=your_private_key_here
  1. Use the facade in your code:
use PHPCore\WertScSigner\Laravel\Facades\WertScSigner;

$dataWithSignature = WertScSigner::signSmartContractData($options);

Function signSmartContractData returns the given options array with an addition of a "signature" property. You can pass the result directly to WertWidget initializer.

Options

Property Required Type Description
address required string User's address that will act as a fallback address if a smart contract can't be executed. In case of fallback, Wert will transfer commodity_amount to this address
commodity required string List of supported currencies
network optional string List of supported currencies
commodity_amount required numeric An amount of crypto necessary for executing the given smart contract
sc_address required string The address of the smart contract
sc_input_data required string Data that will be used for smart contract execution, in the hex format

Example

$commodity = 'ETH';
$network = 'ethereum';
$options = [
    // required generally:
    "partner_id" => "...",

    // required for signing:
    'address' => '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', // NFT receipient
    'commodity_id' => strtolower($commodity) . '_' . strtolower($network) . '.sc.ethereum',
    'commodity' => $commodity,
    'commodity_amount' => 1.5,
    'network' => $network,
    'sc_address' => '0x...', // smart contract address
    'sc_input_data' => '...', // input data (learn more: https://docs.wert.io/docs/forming-input-data)

    // ...
];

$privateKey = 'your_private_key_here';
$dataWithSignature = WertScSigner::signSmartContractData($options, $privateKey);

Private key

Was given to you during your registration in the Wert system as a partner. If you don't have one, contact us.

Requirements

  • PHP 8.0 or higher
  • ext-sodium