xdc3/php

There is no license information available for the latest version (1.0.0) of this package.

By This Library We can Access the XRC20 and XRC721 Methods

1.0.0 2022-01-27 12:09 UTC

This package is auto-updated.

Last update: 2024-04-07 21:23:14 UTC


README

XDC3_PHP SDK with support for smart contracts, XRC20 and XRC721.

This SDK supports the following read and write methods.

XRC20 Token: Read methods XRC20 Token: Write methods
name() approve(receiverAddress , amount)
symbol() transfer(recipient, amount)
decimal() transferFrom(sender, recipient, amount)
totalSupply() increaseAllowance(spender, addedValue)
balanceOf(account) decreaseAllowance(spender, subtractedValue)
allowance(owner, spender)
XRC721 Token: Read methods XRC721 Token: Write methods
name() setApprovalForAll(operatorAddress, booleanValue
symbol() approve(receiverAddress , tokenId)
totalSupply() transferFrom(recipient, tokenId)
balanceOf(owner address) safeTransferFrom(spender, tokenId)
ownerOf(tokenId)
tokenURI(tokenId)
tokenByIndex(index)
tokenOfOwnerByIndex(ownerAddress,index)
supportInterface(interfaceId)
getApproved(tokenId)
isApprovedForAll(ownerAddress, operatorAddress)

Usage

User need to follow the following steps for using the XDCPHP Library.
Step1 :- Create a folder (eg : sdk).
Step2 :- Inside the folder open the command prompt and type 'composer require xdc3/php'.
Step3 :- Create a file (eg : index.php).
Step4 :- After creating user need to add the path, import the classes and create the object.
Step5 :- (optional) If user wants to change the URL of (Apothem testnet Network)  goto vendor -> XDC3 folder -> PHP folder -> .env file and make changes there.

Installation

This library provides simple way to interact with XDC XRC20 & XRC721 tokens.


Before Installing This Library

1.Install php version 7.4.25 in the System.



2.Go to PHP Folder in the system, open php.ini file then enable gmp and curl extensions.

ex: Before it has ';extension=gmp' just remove ";" to enable this Extension.

    Before it has ';extension=curl' just remove ";" to enable this Extension.



3.After that enable this one '(;curl.cainfo =)' and add ssl certificate path here.

  For download this certificate

  go to this url https://curl.se/docs/caextract.html then click on cacert.pem on the top.

  Copy the path of the certificate and paste in php .ini file.

  ex: curl.cainfo = "C:\Users\HP\Downloads\cacert.pem"



4.Install openssl in the system by chocolately.

  Run below command in admin powershell to install openssl.

  ex: choco install openssl
      

Example for XRC20

Test.php
<?php

//path configuration
include "vendor/xdc3/php/library.php";

//Import classes of XDC20
use XRC20\SDK\XRC20SDK;

//Creating a Objects to call the functions of XRC20 and Create a wallet for the User
$obj1 = new XRC20SDK();

//Name func :-
var_dump($obj1->getName($contractAddress));

//GetApprove func:-
var_dump($obj1->getApprove($contractAddress,$ownerAddress,$ownerPrivateKey,$spenderAddress,$tokenAmount));

//TransferFrom func :-
var_dump($obj1->transferFrom($contractAddress,$ownerAddress,$spenderAddress,$spenderPrivateKey,$recieverAddress,$tokenAmount));

//TransferXdc func :-
$obj1->transferXdc($contractAddress,$senderAddress,$senderPrivateKey,$recieverAddress,$xdcAmount);
var_dump($obj1);

//CreateWallet func:-
$obj3 = new createXDCWallet();
$obj3->createWallet();

Example for XRC721

Text.php

<?php

//ex :-//path configuration
include "vendor/xdc3/php/library.php";

//Import classes of XDC721
use XRC721\SDK\XRC721;

//Create a Object
$obj2-> new XRC721();

//Name func :-
var_dump($obj2->getName($contractAddress));

//Symbol func :-
var_dump($obj2->getSymbol($contractAddress));

//TransferOwnership
var_dump($obj2->transfer($contractAddress,$ownerAddress,$recieverAddress,$tokenId,$approvedPrivateKey));

?>