USDT自动上分是通过官方 https://api.trongrid.io 查询接口实现的

在给一个客户做大富彩票自动充值的时候保存的代码,分享给有需要的朋友,不用再去找网上那些带后门的程序了,当然前提是 你得会PHP

只是一个前端充值自动查询并处理的代码,仅供参考,需要前端传参(订单号)后才能进行处理,同样数据库字段也得处理

代码如下:

[php]
function timibbs_usdtautopay($apiparam=array()){
$apiparam = self::_cheacktoken($apiparam);
if(!$apiparam['sign'])return $apiparam;
$trano = $apiparam['trano'];
$payorder = M('recharge')->where(['trano'=>$trano,'state'=>0])->find();

//查询平台收款地址
$usdtpayaddress = M('payset')->field("ftitle")->where("isonline=-1 AND state=1 AND paytype='USDT'")->find();
$to_address = $usdtpayaddress['ftitle'];

//获取地址交易记录
$url = "https://api.trongrid.io/v1/accounts/$to_address/transactions/trc20?limit=10&contract_address=TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
$getData = file_get_contents($url);
$jsonData = json_decode($getData,true);

//循环查询链上记录
foreach ($jsonData["data"] as $k=>$v){
//这里注释掉了,单一订单查询没必要循环所有订单
// foreach ($payorder as $a=>$b){
$from_address = $payorder["from_address"];
$usdtnum = $payorder["usdtnum"];

//转账时间必须大于创建订单时间
if($v['block_timestamp']/1000 > $payorder['oddtime']){

//转账地址、数量完全匹配
if($v['to'] == $to_address && $v['from'] == $from_address && $v['value']/1000000 == $usdtnum){
$userinfo = M('member')->where(['id'=>$payorder['uid']])->find();
$add['oldaccountmoney'] = $userinfo["balance"];
$add['newaccountmoney'] = $userinfo["balance"] + $payorder['amount'];
$add['state'] = 1;
$add['transaction_id'] = $v["transaction_id"];//哈希值
M('recharge')->where(['trano'=>$trano])->setField($add);

//如果上链有数据了就增加余额
M('member')->where(['id'=>$payorder['uid']])->setInc('balance',$payorder['amount']);

//返回
$return['sign'] = true;
$return['state'] = 1;
$return['message'] = '充值成功!';
return $return;exit;
}
}else{
$return['sign'] = false;
$return['message'] = '未发现订单!';
return $return;
}
// }
}
}
[/php]

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。