PHP

Initiate Withdrawal

 <?php

function rsa_encrypt($text, $privateKey) {
    openssl_sign($text, $signature, $privateKey, OPENSSL_ALGO_SHA256);
    return base64_encode($signature);
}

function makeid($length) {
    $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

function initiate_withdrawal() {
    $privateKey = file_get_contents('path/to/your/private_key.pem');
    
    $data = [
        'chain' => 'tron',
        'symbol' => 'trx',
        'address' => 'TJCBzku1S8TPTgyyk3Ja4kepk1BFDQAVq1',
        'amount' => 1,
        'nonce' => makeid(10),
        'timestamp' => time(),
    ];

    $jsonData = json_encode($data);
    $hash = rsa_encrypt($jsonData, $privateKey);

    $postData = [
        'merchant_id' => 'xxxx-xxxx-xxxx-xxxx',
        'hash' => $hash,
        'data' => $data,
    ];

    $ch = curl_init('https://payment.hyperhashing.com/v1/token/withdraw');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));

    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    } else {
        echo 'Request Data: ' . json_encode($postData) . PHP_EOL;
        echo 'Response: ' . $response . PHP_EOL;
    }
    curl_close($ch);
}

initiate_withdrawal();

?>

Check Withdrawal Status

<?php

function rsa_encrypt($text, $privateKey) {
    openssl_sign($text, $signature, $privateKey, OPENSSL_ALGO_SHA256);
    return base64_encode($signature);
}

function makeid($length) {
    $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

function check_withdraw_status() {
    $privateKey = file_get_contents('path/to/your/private_key.pem');
    
    $data = [
        'order_id' => '17188041436139639757',
        'nonce' => makeid(10),
        'timestamp' => time(),
    ];

    $jsonData = json_encode($data);
    $hash = rsa_encrypt($jsonData, $privateKey);

    $postData = [
        'merchant_id' => 'xxxx-xxxx-xxxx-xxxx',
        'hash' => $hash,
        'data' => $data,
    ];

    $ch = curl_init('https://payment.hyperhashing.com/v1/token/withdraw_status');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));

    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    } else {
        echo 'Request Data: ' . json_encode($postData) . PHP_EOL;
        echo 'Response: ' . $response . PHP_EOL;
    }
    curl_close($ch);
}

check_withdraw_status();

?>

Last updated