简体   繁体   中英

NEAR Indexer and 2FA secured wallet transactions

In the Near, transactions signed by a 2FA-protected wallet are done in a special way (contract confirmation) and are not like regular transactions. Signer and receiver id the same wallet. Sample transaction: https://explorer.near.org/transactions/9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY

How to work with them properly, where to find them in Indexer? How do I get the data correctly, what contract and method the user signs?

NEAR Indexer for Explorer core contributor and maintainer here.

Looking at the transaction you've provided in your question https://explorer.near.org/transactions/9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY it was a FUNCTION CALL of the method confirm

And I believe your concern is that you cannot see the result of your transaction in the public NEAR Indexer for Explorer database by querying the transactions table with the hash.

And by saying that 2FA transactions "are not like regular transactions" you mean the nature of cross-contract calls involved.

Here's how to find out what is happening

  1. First of all, let's look for your initial transaction and the Receipt ID it was converted to.
SELECT transaction_hash, converted_into_receipt_id FROM transactions WHERE transaction_hash = '9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY';

               transaction_hash               |          converted_into_receipt_id
----------------------------------------------+----------------------------------------------
 9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY | FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN

According to the fact that this transaction you've sent was a confirmation of some ft_transfer call, we expect that there will happen a cross contract call to the gems.l2e.near contract.

We want to find all the receipts produced after execution of the receipt id FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN (we found it in step 1)

  1. Search for all receipts that were created during the execution of the initial one
SELECT produced_receipt_id FROM execution_outcome_receipts WHERE executed_receipt_id = 'FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN';
             produced_receipt_id
----------------------------------------------
 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU
 3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3
(2 rows)
  1. So we have two other receipts, but we don't actually know what action they are containing. Let's find it out.
SELECT receipt_id, action_kind, receipt_predecessor_account_id, receipt_receiver_account_id, args FROM action_receipt_actions WHERE receipt_id IN ('9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU', '3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3');
                  receipt_id                  |  action_kind  | receipt_predecessor_account_id | receipt_receiver_account_id |                                                                                                               args
----------------------------------------------+---------------+--------------------------------+-----------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3 | TRANSFER      | system                         | shishkerin.near             | {"deposit": "12306467158537048105440"}
 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU | FUNCTION_CALL | shishkerin.near                | gems.l2e.near               | {"gas": 220000000000000, "deposit": "1", "args_json": {"amount": "2970000", "receiver_id": "hot1.l2e.near"}, "args_base64": "eyJyZWNlaXZlcl9pZCI6ImhvdDEubDJlLm5lYXIiLCJhbW91bnQiOiIyOTcwMDAwIn0=", "method_name": "ft_transfer"}
(2 rows)

Here we can see that Receipt 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU is actually making a FUNCTION_CALL to gems.l2e.near signed by shishkerin.near

We can also look at args and find out that the method is calls is ft_transfer and arguments are {"amount": "2970000", "receiver_id": "hot1.l2e.near"}

(The other receipt 3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3 is a transfer signed by system which is basically a cash-back for attached gas)

  1. And just for sanity we'd like to know the execution status of the receipt
SELECT receipt_id, status FROM execution_outcomes WHERE receipt_id = '9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU';
                  receipt_id                  |    status
----------------------------------------------+---------------
 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU | SUCCESS_VALUE

And I hope this answers your question.


In addition to what @khorolets already mentioned, receipts table has originated_from_transaction_hash column which can help you to fetch all the receipts attributed to the transaction:

SELECT * FROM receipts WHERE originated_from_transaction_hash = '9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY';
                  receipt_id                  |            included_in_block_hash            |            included_in_chunk_hash            | index_in_chunk | included_in_block_timestamp | predecessor_account_id | receiver_account_id | receipt_kind |       originated_from_transaction_hash
----------------------------------------------+----------------------------------------------+----------------------------------------------+----------------+-----------------------------+------------------------+---------------------+--------------+----------------------------------------------
 DiL4YA5iyKpsgkwdjdZkuiCatvKHmbVKPGAKpYJV1qS7 | AyX7umWGpR3RgQGnz4LAgTRnRGbF42krvAAjmXo4s4EV | 9VkhZdALu1EY6D2czKaKSV7qQZsLR6vxfAPXqBkgmAGg |              2 |         1644263681934508460 | system                 | shishkerin.near     | ACTION       | 9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY
 3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3 | CyDT5XdZK8pKZM4VP559KxEXvUXTKaZbGVN3mVfoc5TX | FbfPdNLhYZEH3AncDiPa5qQZsaxCL8kfAtEaTV2geDi6 |              3 |         1644263680552610497 | system                 | shishkerin.near     | ACTION       | 9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY
 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU | CyDT5XdZK8pKZM4VP559KxEXvUXTKaZbGVN3mVfoc5TX | FbfPdNLhYZEH3AncDiPa5qQZsaxCL8kfAtEaTV2geDi6 |              2 |         1644263680552610497 | shishkerin.near        | gems.l2e.near       | ACTION       | 9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY
 FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN | 5zvPFNeVytBNWfTzvmBaeCQtDrLuHfujKQqZ7qHhY4di | 4JngM4mhJnM9em6x8e7kJhyiSdPj1A9ZBzze9ZqJM8DP |              0 |         1644263679256841002 | shishkerin.near        | shishkerin.near     | ACTION       | 9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY
(4 rows)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM