简体   繁体   English

NEAR Indexer 和 2FA 安全钱包交易

[英]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.在 Near 中,受 2FA 保护的钱包签署的交易以特殊方式(合约确认)完成,与常规交易不同。 Signer and receiver id the same wallet.签名者和接收者 id 相同的钱包。 Sample transaction: https://explorer.near.org/transactions/9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY交易样本: https://explorer.near.org/transactions/9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY

How to work with them properly, where to find them in Indexer?如何正确使用它们,在 Indexer 中哪里可以找到它们? How do I get the data correctly, what contract and method the user signs?我如何正确获取数据,用户签署什么合同和方式?

NEAR Indexer for Explorer core contributor and maintainer here.此处为 Explorer 核心贡献者和维护者的 NEAR 索引器。

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查看您在问题https 中提供的交易 https://explorer.near.org/transactions/9uPvkdmcL4iNnWrHXZocf7NLAJUUVa4zSMrtFtJhrjcY它是方法confirmFUNCTION CALL

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.我相信您担心的是,通过使用 hash 查询transactions表,您无法在公共NEAR Indexer for Explorer 数据库中看到交易结果。

And by saying that 2FA transactions "are not like regular transactions" you mean the nature of cross-contract calls involved.并且通过说 2FA 交易“不像常规交易”,你的意思是涉及跨合约调用的性质。

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.首先,让我们查找您的初始交易及其转换后的收据 ID。
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.根据您发送的这笔交易是对某个ft_transfer调用的确认,我们预计会对gems.l2e.near合约进行跨合约调用。

We want to find all the receipts produced after execution of the receipt id FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN (we found it in step 1)我们要查找执行收据id FP5UmXxdDBBicGkzgXXdhS28hxgBWVByFcqbwh25qHzN后产生的所有收据(我们在步骤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在这里我们可以看到 Receipt 9zem8CxJvdTHKkZKCc1pFhg4Ky4st6TBrQmE19gv4sAU实际上正在对由gems.l2e.near签名的shishkerin.near进行FUNCTION_CALL

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"}我们也可以查看args,发现method is calls是ft_transfer和arguments是{"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) (另一张收据3mtnLaGFYpXXzZ4H9vYczSXz9JbdS7XueSobDjQDAYb3system签名的转账,基本上是附加 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:除了@khorolets 已经提到的内容之外, receipts表还有originated_from_transaction_hash列,它可以帮助您获取归因于交易的所有收据:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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