-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathact_example.php
37 lines (30 loc) · 918 Bytes
/
act_example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require 'Act.php';
$act = new Act(ACT_RPC_SERVER);
$current_block = $act->getBlockNumber();
if (!$current_block) {
exit;
}
$block = $act->getBlockByNumber($current_block);
if (!$block) {
sleep(10);
}
if (!count($block['user_transaction_ids'])) {
die();
}
foreach ($block['user_transaction_ids'] as $key => $value) {
$trx = $act->blockchainTransaction($value);
$trx = $trx[1]['trx'];
//确认是act交易
if ($trx['act_account'] && 0 == $trx['act_inport_asset']['asset_id'] && ('deposit_op_type' == $trx['operations'][0]['type'] || 'withdraw_op_type' == $trx['operations'][0]['type'])) {
//交易数量
$amount = $trx['act_inport_asset']['amount'] / 100000;
}
//合约交易
if ('transaction_op_type' == $trx['operations'][0]['type']) {
$sub_trx = $trx['operations'][0]['data']['trx'];
if ($sub_trx['act_account']) {
$amount = $sub_trx['act_inport_asset']['amount'] / 100000;
}
}
}