12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace qiniu\services\blockchain\bsc;
- define('ABI_BEP721', file_get_contents('bep721.json'));
- class Bep721 extends SmartContract
- {
- function __construct($client, $credential, $address)
- {
- parent::__construct($client, $credential, ABI_BEP721);
- $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;
- }
- }
|