PHP code example of yativo / crypto-sdk

1. Go to this page and download the library: Download yativo/crypto-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yativo / crypto-sdk example snippets




ativo\YativoSDK;

// Initialize SDK
$yativo = new YativoSDK([
    'base_url' => 'https://crypto-api.yativo.com',
]);

// --- Authentication (passwordless) ---

// Step 1: Request OTP — sends a one-time code to the user's email
$yativo->auth->login('[email protected]');

// Step 2: Verify OTP — returns access token (no password needed)
$response = $yativo->auth->verifyOtp('123456', '[email protected]');

// If the account has 2FA enabled, verify the authenticator code instead
$response = $yativo->auth->verify2fa('654321', '[email protected]');

// Alternatively, authenticate with API key + secret (server-to-server)
$response = $yativo->auth->getToken('yat_your_api_key', 'your_api_secret');

// --- USDC on Solana ---

$account = $yativo->accounts->create('My Account');
$accountId = $account['account']['account_id'];

$solWallet = $yativo->assets->create($accountId, 'solana', 'USDC_SOL');
echo "Solana deposit address: " . $solWallet['asset']['wallet_address'] . "\n";

// Send USDC on Solana (~2-5 second finality)
$yativo->transactions->send([
    'from_asset_id' => $solWallet['asset']['asset_id'],
    'to_address'    => 'RecipientSolanaAddressHere',
    'amount'        => '10.00',
    'chain'         => 'solana',
    'ticker'        => 'USDC_SOL',
]);

// --- USDC on XDC ---

$xdcWallet = $yativo->assets->create($accountId, 'xdc', 'USDC_XDC');
echo "XDC deposit address: " . $xdcWallet['asset']['wallet_address'] . "\n";

// Send USDC on XDC (~2 second finality, ultra-low fees)
$transaction = $yativo->transactions->send([
    'from_asset_id' => $xdcWallet['asset']['asset_id'],
    'to_address'    => 'xdcRecipientAddressHere',
    'amount'        => '50.00',
    'chain'         => 'xdc',
    'ticker'        => 'USDC_XDC',
]);

echo "Transaction hash: " . $transaction['transaction']['tx_hash'] . "\n";