|
|
@@ -21,8 +21,8 @@ class BscApi
|
|
|
{
|
|
|
protected $transactionLimt = 1;//识别到的最小到账金额,低于此值的到账金额不入账
|
|
|
|
|
|
- protected $bsc_api_key = 'VTCKIP346DCRWB6JNS4KDANUJJEQN9VAKW';
|
|
|
-
|
|
|
+ protected $bsc_api_key = '8TP62I7UJF2AY7TAH3TAR4R3IM7N9ZCHP2';
|
|
|
+ protected $bsc_api_url = 'https://api.etherscan.io/v2/api?chainid=56';//56为币安链主网ID
|
|
|
protected $contract_address = '0x55d398326f99059ff775485246999027b3197955';//交易币种的合约地址,默认为usdt的:0x55d398326f99059ff775485246999027b3197955,测试合约:0xcf3271b1be72f834e4dd35b9d558d583894473f1
|
|
|
/**
|
|
|
* value的放大比例 固定为: 10的18次方
|
|
|
@@ -54,7 +54,7 @@ class BscApi
|
|
|
return _error('hash不能为空');
|
|
|
}
|
|
|
// 读取远程页面地址
|
|
|
- $url = "https://bscscan.com/tx/" . $tx_hash;
|
|
|
+ $url = $this->bsc_api_url . "tx/" . $tx_hash;
|
|
|
dump($url);
|
|
|
// 使用 file_get_contents 函数读取远程页面
|
|
|
//$html = file_get_contents($url);
|
|
|
@@ -183,7 +183,7 @@ class BscApi
|
|
|
}
|
|
|
|
|
|
// 读取远程页面地址
|
|
|
- $url = "https://api.bscscan.com/api?module=account&action=tokentx&contractaddress=" . $this->contract_address;
|
|
|
+ $url = $this->bsc_api_url . "&module=account&action=tokentx&contractaddress=" . $this->contract_address;
|
|
|
$url .= "&page=1&offset=10000&endblock=" . $end_block ."&apikey=" . $this->bsc_api_key;
|
|
|
$url .= "&startblock=" . $start_block . "&address=" . $address;
|
|
|
Log::log($url);
|
|
|
@@ -286,7 +286,7 @@ class BscApi
|
|
|
return _error('hash值不能为空');
|
|
|
}
|
|
|
|
|
|
- $url = "https://api.bscscan.com/api?module=transaction&action=gettxreceiptstatus";
|
|
|
+ $url = $this->bsc_api_url . "&module=transaction&action=gettxreceiptstatus";
|
|
|
$url .= "&apikey=" . $this->bsc_api_key;
|
|
|
$url .= "&txhash=" . $tx_hash;
|
|
|
|
|
|
@@ -332,7 +332,7 @@ class BscApi
|
|
|
|
|
|
//https://api.bscscan.com/api?module=block&action=getblocknobytime×tamp=1601510400&closest=before&apikey=YourApiKeyToken
|
|
|
|
|
|
- $url = "https://api.bscscan.com/api?module=block&action=getblocknobytime&";
|
|
|
+ $url = $this->bsc_api_url . "&module=block&action=getblocknobytime&";
|
|
|
$url .= "&closest=before";//closest 值还有个参数 after 控制返回接近时间戳之前还是之后的区块高度
|
|
|
$url .= "&apikey=" . $this->bsc_api_key;
|
|
|
$url .= "×tamp=" . $time;
|
|
|
@@ -391,7 +391,7 @@ class BscApi
|
|
|
return _error('钱包地址不能为空');
|
|
|
}
|
|
|
|
|
|
- $url = "https://api.bscscan.com/api?module=account&action=balance";
|
|
|
+ $url = $this->bsc_api_url . "&module=account&action=balance";
|
|
|
$url .= "&apikey=" . $this->bsc_api_key;
|
|
|
$url .= "&address=" . $address;
|
|
|
|
|
|
@@ -435,7 +435,7 @@ class BscApi
|
|
|
$contract_address = $this->contract_address;
|
|
|
}
|
|
|
|
|
|
- $url = "https://api.bscscan.com/api?module=account&action=tokenbalance";
|
|
|
+ $url = $this->bsc_api_url . "&module=account&action=tokenbalance";
|
|
|
$url .= "&apikey=" . $this->bsc_api_key;
|
|
|
$url .= "&address=" . $address;
|
|
|
$url .= "&contractaddress=" . $contract_address;
|