<?php

function queryAssetInfo($api_key, $api_secret) {
    // Set the API endpoint
    $url = 'https://api.bybit.com/v5/asset/transfer/query-asset-info/';

    // Generate the current timestamp in milliseconds
    //$timestamp = (string)(microtime(true) * 1000);
    
    $timestamp=get_timestamp();
    

    // Create the string to sign
    $params = "api_key={$api_key}&timestamp={$timestamp}";

    // Generate the signature
    $signature = hash_hmac('sha256', $params, $api_secret);

    // Build the complete URL with query parameters
    $full_url = "{$url}?{$params}&sign={$signature}";

    // Initialize cURL
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $full_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Execute the request
    $response = curl_exec($ch);

    // Check for errors
    if ($response === false) {
        echo 'cURL Error: ' . curl_error($ch);
    } else {
        // Decode the JSON response
        $data = json_decode($response, true);
        print_r($data);
    }

    // Close cURL
    curl_close($ch);
}


function get_timestamp()
{
    $ch = curl_init();
    // Set the URL and other cURL options
    curl_setopt($ch, CURLOPT_URL, "https://api.bybit.com/v5/time");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // Execute the request and get the response
    $response = curl_exec($ch);
    // Close the cURL session
    curl_close($ch);
    // Decode the JSON response
    $serverTime = json_decode($response, true);
    return $serverTime['serverTime'];

}

// Replace with your API key and secret
$api_key = 'ZwEzFeiqnVo356Our9';
$api_secret = 'pKpGWLUSjwnXP3A2QXEhTuc5O30cSvXwoSMp';

queryAssetInfo($api_key, $api_secret);

?>