定制 sound/sound-sdk-php-demo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sound/sound-sdk-php-demo

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sound/sound-sdk-php-demo

包简介

sound-sdk-php

README 文档

README

#sound/sound-sdk-php-demo

Install

composer require sound/sound-sdk-php-demo

Usage

生成秘钥对、地址

use crichain\Creator;

$keyPair = Creator::keyPair();

签名

use crichain\Creator;

/**
 * 签名
 *
 * @param string $privateKey 私钥
 * @param string $msg
 * @return string
 * @throws Exception
 */
$sign = Creator::sign($keyPair['privateKey'], '123');

获取账户信息

use crichain\Caller;

/**
 * 获取账号信息
 *
 * @param string $address 地址
 * @return array
 * @throws Exception
 */
$accountInfo = Caller::getAccountInfo($keyPair['address']);

转账CRIC

use crichain\Transfer;

/**
 * construct
 *
 * @param string $privateKey 私钥
 * @throws Exception
 */
$transfer = new Transfer($keyPair['privateKey']);

/**
 * 转账
 *
 * @param string $to 转入地址
 * @param string $amount 转账金额
 * @return array|mixed
 * @throws Exception
 */
$res = $transfer->safeTransfer('转入地址', '0.01');
//$res = $transfer->safeTransfer('转入地址', '0.01', 10); // 手动传入 nonce

调用合约

use crichain\Caller;
use crichain\utils\Functions;

/**
 * 实例化调用合约类
 * 
 * @param string $privateKey 私钥
 * @param string $nftType NFT配置,默认为NFT_A
 */
$caller = new Caller($privateKey);

/**
 * 铸造
 *
 * @param string $contractAddress   合约地址
 * @param string $method  合约方法名:safeMint
 * @param array $params  合约参数数组:['转入地址','tokenId','token图片地址']
 * @param string $operateId  操作ID
 * @return array|mixed
 * @throws Exception
 */
$r = $caller->callContract($contractAddress, 'safeMint',['xxxx','123','https://gfanx.cn/1.jpg'], Functions::createOperateId());
var_dump($r); die;

/**
 * 转移token
 *
 * @param string $contractAddress   合约地址
 * @param string $method  合约方法名:safeTransfer
 * @param array $params  合约参数数组:['转出地址','转入地址','tokenId']
 * @param string $operateId  操作ID
 * @return array|mixed
 * @throws Exception
 */
$r = $caller->callContract($contractAddress, 'safeTransfer',['xxx','xxx','123'],  Functions::createOperateId());
var_dump($r); die;

/**
 * 销毁
 *
 * @param string $contractAddress   合约地址
 * @param string $method  合约方法名:burn
 * @param array $params  合约参数数组:['tokenId']
 * @param string $operateId 操作ID
 * @return array|mixed
 * @throws Exception
 */
$r = $caller->callContract($contractAddress, 'burn',['123'], Functions::createOperateId());
var_dump($r); die;

/**
 * 获取tokenURI
 *
 * @param string $contractAddress   合约地址
 * @param string $method  合约方法名:tokenURI
 * @param array $params  合约参数数组:['tokenId']
 * @return array|mixed
 * @throws Exception
 */
$r = $caller->callContract($contractAddress, 'tokenURI',['123']);
var_dump($r); die;

#注:其他合约方法,见config/NFT_A.json配置文件,调用方法同上。

获取交易详情

/**
 * 获取交易详情
 *
 * @param string $hash 交易哈希
 * @return array
 * @throws Exception
 */
$r = crichain\Caller::transactionInfo('xxx');
var_dump($r);

注意事项

1.sdk区分测试与正式环境,如需要使用测试环境,请增加环境变量:CRICHAIN_SDK_ENV=test

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固