How to get transaction detail when transfer is token?
How to get transaction detail when the transfer is a token?
https://github.com/Fenguoz/bsc-php/blob/916a96185790d50dc0e838ae19543f4e0fce1cd4/README.md?plain=1#L35
@Fenguoz Hi It didn't get transaction detail when it is token transfer.
my code is:
$uri = 'https://bsc-dataseed1.defibit.io/';// Mainnet
$api = new \Binance\NodeApi($uri);
$config = [
'contract_address' => '0x55d398326f99059ff775485246999027b3197955',// USDT BEP20
'decimals' => 18,
];
$bep20 = new \Binance\BEP20($api, $config);
$txHash = '0x60c6ff9b16ddf2372cb7f8a1c02c990ae5c93162cf0bc8a866000a122dfba401';
var_dump($bep20->getTransactionReceipt($txHash));
output :
array(14) {
["blockHash"]=>
string(66) "0xfaa6ab98a791e6ef6cb70ebc9d611f074325b5550e0fae4972c2a8c1262c8ba7"
["blockNumber"]=>
string(9) "0x1b694c6"
["contractAddress"]=>
NULL
["cumulativeGasUsed"]=>
string(8) "0xb67fb6"
["effectiveGasPrice"]=>
string(10) "0xb2d05e00"
["from"]=>
string(42) "0x392760369e0d81a156d7231a3fe177dba97dd22b"
["gasUsed"]=>
string(6) "0x527b"
["logs"]=>
array(1) {
[0]=>
array(9) {
["address"]=>
string(42) "0x55d398326f99059ff775485246999027b3197955"
["topics"]=>
array(3) {
[0]=>
string(66) "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
[1]=>
string(66) "0x000000000000000000000000392760369e0d81a156d7231a3fe177dba97dd22b"
[2]=>
string(66) "0x00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a6"
}
["data"]=>
string(66) "0x0000000000000000000000000000000000000000000000056bc75e2d63100000"
["blockNumber"]=>
string(9) "0x1b694c6"
["transactionHash"]=>
string(66) "0x60c6ff9b16ddf2372cb7f8a1c02c990ae5c93162cf0bc8a866000a122dfba401"
["transactionIndex"]=>
string(4) "0x6f"
["blockHash"]=>
string(66) "0xfaa6ab98a791e6ef6cb70ebc9d611f074325b5550e0fae4972c2a8c1262c8ba7"
["logIndex"]=>
string(4) "0xcd"
["removed"]=>
bool(false)
}
}
["logsBloom"]=>
string(514) "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010080000000000000001000008000000000000000
000000000000200000000000000400000000000000000000000000000000000000000000000000010000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000020000000000000000000200000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000"
["status"]=>
string(3) "0x1"
["to"]=>
string(42) "0x55d398326f99059ff775485246999027b3197955"
["transactionHash"]=>
string(66) "0x60c6ff9b16ddf2372cb7f8a1c02c990ae5c93162cf0bc8a866000a122dfba401"
["transactionIndex"]=>
string(4) "0x6f"
["type"]=>
string(3) "0x0"
}
There is no detail about the amount and which address get tokens.
Added getTransactionByHash interface to update the latest package can be used
https://github.com/Fenguoz/bsc-php/blob/b6d72bb6ddd2e178f9e8811b6697cac85ac90a0a/README.md?plain=1#L36
array(15) {
["blockHash"]=>
string(66) "0xfaa6ab98a791e6ef6cb70ebc9d611f074325b5550e0fae4972c2a8c1262c8ba7"
["blockNumber"]=>
string(9) "0x1b694c6"
["from"]=>
string(42) "0x392760369e0d81a156d7231a3fe177dba97dd22b"
["gas"]=>
string(7) "0x30d40"
["gasPrice"]=>
string(10) "0xb2d05e00"
["hash"]=>
string(66) "0x60c6ff9b16ddf2372cb7f8a1c02c990ae5c93162cf0bc8a866000a122dfba401"
["input"]=>
string(138) "0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000"
["nonce"]=>
string(5) "0x3ee"
["to"]=>
string(42) "0x55d398326f99059ff775485246999027b3197955"
["transactionIndex"]=>
string(4) "0x6f"
["value"]=>
string(3) "0x0"
["type"]=>
string(3) "0x0"
["v"]=>
string(4) "0x93"
["r"]=>
string(66) "0x1c59dfc1ab96126010300040e451375aaa13b15f86930df72e3fe09b2928a951"
["s"]=>
string(66) "0x44b25765a3268e457013ec144caa6532d476aae17f96a84449155527dfbdced1"
}
Yet no detail about token transaction.
You must decode this, Here are the details of the token transaction.
["input"]=> string(138) "0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000"
This part refers to the token contract address: USDT
["to"]=> string(42) "0x55d398326f99059ff775485246999027b3197955"
You need to decode the 'input' using an 'ABI' decoder.
@kendol07 Can you give me ABI decoder?
Use this repository that I have created for you: https://github.com/kendol07/eth_abi_decoder".
@Fenguoz @kendol07 I think we need to add a method that decodes.
@Fenguoz if you want you can use my code to implement here.
I have created this latest version, which can decode input data from ERC20, BEP20, Polygon, and all Ethereum-based transfer transactions, without needing an ABI. It's easy to use, and it can be improved and adapted to this same project. It allows for the decoding of BEP20 transactions of USDT, USDC, and any other token.
https://github.com/kendol07/Ethereum.Input.Data.Decoder
@kendol07 Could please give us example to use it.
You pass the parameter ["input"]=> string(138) "0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000" and decode it using the function available at https://github.com/kendol07/Ethereum.Input.Data.Decoder. Upon decoding, you will obtain the recipient and the amount of the USDT transaction and any other token.
Example:
require DIR."/vendor/autoload.php"; require 'decoder.php';
$inputData='0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000';
$result= DecodeDataInput($inputData); echo $result;
Example result: { "address": "0x123...", "value": "10000" //wei }
You pass the parameter ["input"]=> string(138) "0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000" and decode it using the function available at https://github.com/kendol07/Ethereum.Input.Data.Decoder. Upon decoding, you will obtain the recipient and the amount of the USDT transaction and any other token.
Example:
require DIR."/vendor/autoload.php"; require 'decoder.php';
$inputData='0xa9059cbb00000000000000000000000065624442e8916b8cd4bc7c57388461bdc1bbe1a60000000000000000000000000000000000000000000000056bc75e2d63100000';
$result= DecodeDataInput($inputData); echo $result;
Example result: { "address": "0x123...", "value": "10000" //wei }
its not work. Warning: Undefined array key "value" in decoder.php on line 34 i put input from getTransactionByHash
I have created this latest version, which can decode input data from ERC20, BEP20, Polygon, and all Ethereum-based transfer transactions, without needing an ABI. It's easy to use, and it can be improved and adapted to this same project. It allows for the decoding of BEP20 transactions of USDT, USDC, and any other token.
https://github.com/kendol07/Ethereum.Input.Data.Decoder
even im testing using from your input data, its error too. are done testing in other platform?
Test it now, the code has been modified. It had a small error because I translated it into English for you to understand.
Test it now, the code has been modified. It had a small error because I translated it into English for you to understand.
ok its work, are you know how to get transaction by address?
I use the scanning of transactions by blocks and in each transaction of the block, I check if the recipient belongs to any of my wallets. But you can also use this API that allows you to obtain transactions by address.
https://docs.bscscan.com/api-endpoints/accounts#get-a-list-of-normal-transactions-by-address
i dont want via bsc api, i want from rpc so it free, can you help me?
I use the scanning of transactions by blocks and in each transaction of the block, I check if the recipient belongs to any of my wallets. But you can also use this API that allows you to obtain transactions by address.
https://docs.bscscan.com/api-endpoints/accounts#get-a-list-of-normal-transactions-by-address
Register on BSC and you will get an API, it's free for some features including Transactions by Address.
free but limit, there are no features get tx by address? eth_getLogs i think its not work now
I use block scanning. A script scans the new blocks, and when it finds a transaction that corresponds to your wallet, you store it for whatever use you want.Other than that, I couldn't help you; I don't use address scanning in any other way than what has already been explained.