PHP code example of ceseshi / vottun-php-sdk

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

    

ceseshi / vottun-php-sdk example snippets




use Vottun\VottunClient;
use Vottun\ERCv1\ERC20Client;

$vottunApiKey = 'your_api_key_here';
$vottunApplicationVkn = 'your_application_vkn_here';
$vottunClient = new VottunClient($vottunApiKey, $vottunApplicationVkn);
$network = 80002; // Amoy testnet

$erc20token = new ERC20Client($vottunClient, $network, null);

$name = 'MyToken';
$symbol = 'MTK';
$decimals = 18;
$initialSupply = strval(\Web3\Utils::toWei("1000000", 'ether')); // Initial supply in Wei

$transactionHash = $erc20token->deploy($name, $symbol, $decimals, $initialSupply);
$contractAddress = $erc20token->getContractAddress();

echo "Deploy hash: {$transactionHash}";
echo "Deploy address: {$contractAddress}";

$contractAddress = 'your_contract_address_here';
$erc20token = new ERC20Client($vottunClient, $network, $contractAddress);

$recipientAddress = 'recipient_address_here';
$amount = strval(\Web3\Utils::toWei("100.001", 'ether')); // Amount in Wei

$transactionHash = $erc20token->transfer($recipientAddress, $amount);
$balance = $erc20token->balanceOf($recipientAddress);

echo "Transfer hash: {$transactionHash}";
echo "Recipient balance: {$balance}";

$contractAddress = 'your_contract_address_here';
$erc721token = new ERC721Client($vottunClient, $network, $contractAddress);

$recipientAddress = 'recipient_address_here';
$ipfsUri = 'ipfs_uri_here';
$ipfsHash = 'ipfs_hash_here';
$royaltyPercentage = 10;
$tokenId = 1;

$transactionHash = $erc721token->mint($recipientAddress, $tokenId, $ipfsUri, $ipfsHash, $royaltyPercentage);
echo "Mint hash: {$transactionHash}";
bash
composer