PHP code example of chainlife / safecustody_sdk_php
1. Go to this page and download the library: Download chainlife/safecustody_sdk_php 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/ */
chainlife / safecustody_sdk_php example snippets
namespace main;
se safecustody\User;
$user = new User();
//对应商户后台的APPID
$user->setAppid("");
//对应商户后台的商户ID
$user->setUserId("");
//对应商户后台的SECRETKEY
$user->setSecretKey("");
//对应商户后台的APIKEY
$user->setApiKey("");
$sdk = new Sdk($user);
//TODO 请向微信群里面的官方人员获取
$sdk->setHost("");
//传入查询的币名
var_dump($sdk->QueryCoinConf("btc"));
var_dump($sdk->QueryCoins());
/**
* @param string coin 币名
* @param string chain 链名
*/
var_dump($sdk->QueryBalance(["chain" => "eth", "coin" => "usdt"]));
/**
* @param string coin 币名
* @param string chain 链名
* @param string subuserid 你的用户id
*/
var_dump($sdk->GetDepositAddr(["chain" => "eth", "coin" => "usdt", "subuserid"=>"1"]));
/**
* @param string coin 主链 (空字符串默认不做筛选)
* @param string chain 币名 (空字符串默认不做筛选)
* @param string subuserid 子账号,平台不管其含义(空字符串默认不做筛选)
* @param int fromid 从哪个充值序号开始,值大于等于1,查询结果包含fromId对应的充值记录
* @param int limit 最多查询多少条记录,包含fromid这条记录
*/
var_dump($sdk->GetDepositHistory($subuserId = "1", $chain = "trx", $coin = "trx", $fromid = 1, $limit = 100));
/**
* @param string coin 币名
* @param string chain 链名
* @param string addr 要查询的内部地址
*/
var_dump($sdk->QueryIsInternalAddr($coin = "btc", $chain = "btc", $addr = ""));
/**
* @param string coin 币名
* @param string chain 链名
* @param string subuserid 你的用户id
* @param string addr 提币地址
* @param string amount 提币数量
* @param string memo 该字段主要提供给链上支持备注的币种,内容会更新到链上
* @param string usertags 用户标签,自定义内容,一般作为订单备注使用,辅助说明
* @param string user_orderid 用户自定义订单ID,该字段主要是填写用户系统的订单流水号,字段具有唯一性(可选字段)
*/
var_dump($sdk->SubmitWithdraw($subuserId = "26", $chain = "trx", $coin = "trx", $addr = "", $amount = "10", $memo = "test", $usertags = "my",$userOrderid=""));
/**
* @param string coin 币名
* @param string chain 链名
* @param string subuserid 子账号,平台不管其含义(空字符串默认不做筛选)
* @param string addr 提币地址
* @param string amount 提币数量
* @param string memo 该字段主要提供给链上支持备注的币种,内容会更新到链上
* @param string usertags 用户标签, 自定义内容,一般作为订单备注使用,辅助说明
* @param string user_orderid 用户自定义订单ID,该字段主要是填写用户系统的订单流水号,字段具有唯一性(可选字段)
*/
var_dump($sdk->ValidateWithdraw($subuserId = "26", $chain = "trx", $coin = "trx", $addr = "", $amount = 0, $memo = "test", $usertags = "my",$userOrderid=""));
/**
* @param string coin 币名
* @param string chain 链名
* @param string withdrawid 提币订单ID
*/
var_dump($sdk->QueryWithdrawStatus($coin = "btc", $chain = "btc", $withdrawid = "1"));
/**
* @param string coin 币名
* @param string chain 链名
* @param string subuserid 子账号,平台不管其含义(空字符串默认不做筛选)
* @param int fromid 从哪个充值序号开始,值大于等于1,查询结果包含fromId对应的充值记录
* @param int limit 最多查询多少条记录,包含fromid这条记录
*/
var_dump($sdk->QueryWithdrawHistory($subuserId = "1", $chain = "btc", $coin = "btc", $fromid = 1, $limit = 100));
/**
* 取消提币接口
* @param string $subuserId 子账号,平台不管其含义(空字符串默认不做筛选)
* @param string $chain链名
* @param string $coin 币名
* @param string $withdrawid 提币订单ID
* @return mixed
*/
var_dump($sdk->WithdrawCancel($subuserId = "1", $chain = "btc", $coin = "btc", $withdrawid = "1"));
/**
* 查询区块高度
* @param $chain
* @param $coin
* @return mixed
*/
var_dump($sdk->BlockHeight($chain = "btc", $coin = "btc"));
composer
+---------------------------------------------------------------------------------------------+
|~:cmd> mkdir project |
|~:cmd> cd project |
|./project:cmd> composer |
+──-------------------------------------------------------------------------------------------+