ceseshi/vottun-php-sdk

Vottun PHP SDK


License
Other

Documentation

Vottun PHP SDK

The Vottun PHP SDK provides an easy-to-use PHP interface to interact with the Vottun API, initially designed for operations with ERC20 and ERC721 tokens on the Ethereum blockchain. This SDK simplifies the process of integrating Vottun API functionalities into your PHP applications, including token transfers, querying balances, and managing allowances.

This software is not officially affiliated with Vottun.

License: LGPL v3

Author

Features

  • Deploy and mint ERC20 tokens
  • Deploy and mint ERC721 NFTs
  • Transfer tokens
  • Manage allowances
  • Query token balances
  • Support for big number operations
  • Easy to integrate with PHP projects

Requirements

Folder structure

β”œβ”€β”€ examples                  # Example scripts
β”œβ”€β”€ lib                       # Libraries
β”‚   └── Web3                  # web3p/web3.php library
β”‚       └── Utils.php         # The web3.php Utils class, used to manage big numbers.
└── src                       # Source files
    β”œβ”€β”€ VottunClient.php      # The main VottunClient class, used to interact with the Vottun API.
    └── ERCv1                 # Vottun ERC v1 API clients
        β”œβ”€β”€ ERC20Client.php   # The ERC20Client class, used to interact with ERC20 tokens.
        └── ERC721Client.php  # The ERC721Client class, used to interact with ERC721 tokens.

Installation

Run the following command in your project directory to add the Vottun PHP SDK as a dependency:

composer require ceseshi/vottun-php-sdk

Usage

Here's a quick start guide on how to use the Vottun PHP SDK in your project.

Initialize the Client

require_once 'vendor/autoload.php';

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

$vottunApiKey = 'your_api_key_here';
$vottunApplicationVkn = 'your_application_vkn_here';
$vottunClient = new VottunClient($vottunApiKey, $vottunApplicationVkn);
$network = 80001; // Mumbai

Deploy ERC20

$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}";

Transfer ERC20

$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}";

Mint ERC721

$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}";

Pending features

  • ERC1155 Client
  • POAP Client
  • Web3 Core Client
  • IPFS Client
  • Custodied Wallets Client
  • Balances Client
  • Estimate Gas Client

Contributing

Contributions to the Vottun PHP SDK are welcome. Please ensure that your contributions adhere to the following guidelines:

  • Fork the repository and create your branch from main.
  • If you've added code that should be tested, add tests.
  • Ensure the test suite passes.
  • Issue that pull request!

Support

If you encounter any issues or require assistance, please open an issue on the GitHub repository.

License

This project is licensed under the LGPL. See the LICENSE file for details.

Acknowledgments

  • Thanks to the Vottun team for providing the API.