The Circular
class is a PHP implementation for interacting with the Circular Labs blockchain. It provides methods for performing various operations such as fetching wallet information, registering a wallet, fetching asset information, and sending transactions.
This class requires the following dependencies:
First, you need to install Composer and then run the following command to install the Elliptic library:
composer require elliptic/php
Description of the methods available in the Circular class:
__construct()
: Initializes the elliptic curve cryptography (ECC) object.setNAGKey($NAGKey)
: Sets the NAG key.setNAGURL($NURL)
: Sets the NAG URL.getWallet($blockchain, $address)
: Fetches the wallet information for a given blockchain and address.registerWallet($blockchain, $privateKey)
: Registers a wallet on a given blockchain using a private key.getAsset($blockchain, $name)
: Fetches asset information for a given blockchain and asset name.getAssetSupply($blockchain, $name)
: Fetches the supply of a given asset on a specific blockchain.getBlock($blockchain, $num)
: Fetches block information for a given blockchain and block number.sendTransaction($id, $from, $to, $timestamp, $type, $payload, $nonce, $publicKey, $signature, $blockchain)
: Sends a transaction on a given blockchain.Example of how to use the Circular class:
<?php
// Include the Circular class from the lib directory
require_once 'lib/CIRCULAR.php';
// Create a new instance of the Circular class
$circular = new \lib\Circular();
// Set the NAG key and URL
$circular->setNAGKey('your_nag_key');
$circular->setNAGURL('https://nag.circularlabs.io/NAG.php?cep=');
// Register a wallet
$blockchain = 'your_blockchain';
$privateKey = 'your_private_key';
$response = $circular->registerWallet($blockchain, $privateKey);
// Check the response
if ($response) {
echo "Wallet registered successfully.\n";
} else {
echo "Failed to register wallet.\n";
}
// Get wallet information
$address = 'your_address';
$walletInfo = $circular->getWallet($blockchain, $address);
// Print the wallet information
echo "Wallet Information: \n";
print_r($walletInfo);
?>
Note: Replace 'your_nag_key', 'your_blockchain', 'your_private_key', and 'your_address' with your actual values.
This class is provided as-is, and it is up to the user to ensure that it is used correctly and securely. Always remember to keep your private keys secure and never share them with anyone. Always test your code thoroughly before deploying it in a production environment.