xdc3 / php
此包最新版本(1.0.0)没有可用的许可信息。
通过这个库,我们可以访问XRC20和XRC721方法
1.0.0
2022-01-27 12:09 UTC
Requires
- sop/asn1: ^3.3
- sop/crypto-encoding: ^0.2.0
- sop/crypto-types: ^0.2.1
- xdc3base/php: 1.1.0
This package is auto-updated.
Last update: 2024-09-07 22:08:42 UTC
README
支持智能合约、XRC20和XRC721的XDC3_PHP SDK。
此SDK支持以下读写方法。
使用方法
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.
安装
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
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();
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)); ?>