PHP code example of ledgefarm / ledgefarmcore

1. Go to this page and download the library: Download ledgefarm/ledgefarmcore 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/ */

    

ledgefarm / ledgefarmcore example snippets



use Ledgefarm\LedgefarmCore\LedgefarmCore;

 function __construct()
 {
         LedgefarmCore::setGlobalConfigurations(
            'lf_core_test_6847437634763763476343763376237632276',
            'https://LedgefarmCore.com/api/v2',
            'op1.crt',
            'op1.key',
            'abcd1234'
        );
 }



use Ledgefarm\LedgefarmCore\Wallet;
use Ledgefarm\LedgefarmCore\Fee;
use Ledgefarm\LedgefarmCore\Operator;
use Ledgefarm\LedgefarmCore\Token;
use Ledgefarm\LedgefarmCore\Transaction;
use SebastianBergmann\Exporter\Exception;

public $feeObj;

class Client {
    
    public function __construct()
    {
            $this->feeObj = new Fee('q1w2e37ur4t6', '0.1', 'operator fee');
    }

    public function create()
    {
            try
            {
                $wallet = new Wallet('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
                $resp = $wallet->create('q1w2e37ur4t5', 'test', '[email protected]', '+91', '12345678', 'avatar', true);
                print_r($resp);
            }
            catch(Exception $e)
            {
                echo $e->getMessage(); 
            }
    }
}

public function get()
{
        try
        {
            $wallet = new Wallet('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $wallet->get('q1w2e37ur4t5');
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function getAll()
{
        try
        {
            $wallet = new Wallet('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $wallet->getAll(10, 1);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function update()
{
        try
        {
            $wallet = new Wallet('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $wallet->update('q1w2e37ur4t5', 'testUser', '[email protected]', '+91', '12345678', 'avatar', true, false);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function search()
{
        try
        {
            $wallet = new Wallet('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $wallet->search('12345678', '+91');
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function get()
{
        try
        {
            $operator = new Operator('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $operator->get();
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function ownedToken()
{
        try
        {
            $operator = new Operator('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $operator->ownedToken();
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function issuedToken()
{
        try
        {
            $operator = new Operator('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $operator->issuedToken();
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}


public function issue()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $feeArray = array($this->feeObj);
            $resp = $token->issue('q1w2e37ur4t5', 'USD', 1, $feeArray);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function transfer()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $feeArray = array($this->feeObj);
            $resp = $token->transfer('q1w2e37ur4t5', 'USD', 1, $feeArray);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function batchTransfer()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $feeArray = array($this->feeObj);
            $batchTransferArray = array($this->batchTransferObj);
            $resp = $token->batchTransfer('USD', 10, 'Transfer', $feeArray, $batchTransferArray);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function withdraw()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $feeArray = array($this->feeObj);
            $resp = $token->withdraw('q1w2e37ur4t5', 'USD', 1, $feeArray);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function request()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $resp = $token->request('q1w2e37ur4t5', 'USD', 1);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function accept()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $feeArray = array($this->feeObj);
            $resp = $token->accept('lf_core_test_foe14124f6assf7sfas', $feeArray);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function reject()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $feeArray = array($this->feeObj);
            $resp = $token->reject('lf_core_test_foe14124f6assf7sfas');
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function get()
{
        try
        {
            $token = new Token('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dd');
            $resp = $token->get('USD');
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function getAll()
{
        try
        {
            $transaction = new Transaction('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $transaction->getAll(10, 1);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function get()
{
        try
        {
            $transaction = new Transaction('lf_core_test_445e4s5C453srtrtarg3s9sHsrtr34trqL4yjsWsD34sffarjtT1zdfp7dc');
            $resp = $transaction->get('ehruew3235dsfsh332');
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function getAllByToken()
{
        try
        {
            $transaction = new Transaction('xxxxxxxxxxxxxxxxxxxxxx');
            $limit = 10;
            $offset = 1;
            $resp = $transaction->getAllByToken('USD', $limit, $offset);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}

public function getAllByWallet()
{
        try
        {
            $transaction = new Transaction('xxxxxxxxxxxxxxxxxxxxxx');
            $limit = 10;
            $offset = 1;
            $resp = $transaction->getAllByWallet('abc@wallxxxx', $limit, $offset);
            print_r($resp);
        }
        catch(Exception $e)
        {
            echo $e->getMessage(); 
        }
}