123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace qiniu\services\blockchain\bsc;
- define('ABI_BEP20', file_get_contents(QINIU_PATH . 'services/blockchain/bsc/json/bep20.json'));
- //define('EVENTSIG_TRANSFER', '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
- class Bep20 extends SmartContract
- {
- function __construct($client, $credential, $address)
- {
- parent::__construct($client, $credential, ABI_BEP20);
- $this->at($address);
- }
- function getTransferEvents($from = [], $to = [], $fromBlock = 'latest', $toBlock = 'latest')
- {
- $toTopic = function ($addr) {
- $addr = preg_replace('/^0x/', '', $addr);
- return '0x' . str_pad($addr, 64, '0', STR_PAD_LEFT);
- };
- $from = array_map($toTopic, $from);
- $to = array_map($toTopic, $to);
- return $this->queryEvents([EVENTSIG_TRANSFER, $from, $to], $fromBlock, $toBlock);
- }
- function getBlockNumber()
- {
- $cb = new Callback();
- $this->eth->blockNumber($cb);
- return $cb->result->toString();
- }
- function getTransactionReceipt($tx_hash)
- {
- $cb = new Callback();
- $this->eth->getTransactionReceipt($tx_hash, $cb);
- return $cb->result;
- }
- }
|