Erc-20

為什麼這筆交易成功轉移了超過其餘額?

  • May 3, 2022

在 BSC 鏈上,此交易正在鑄造 NFT(MstToken)。evm 跟踪顯示它呼叫MstToken.transferFrom(fromUser, ..., 0x30927f74c9de0000)發送 0x30927f74c9de0000 令牌並成功,返回值為 1:

{
 "type": "CALL",
...
 "calls": [
   {
     "type": "DELEGATECALL",
     ...
     "calls": [
       {
         "type": "CALL", // <-- `transferFrom(user, ..., 0x30927f74c9de0000)`, returns true
         ...
         "input": "0x23b872dd0000000000000000000000009b57b60f14fea2b9889f203ed29db879060147dc000000000000000000000000edc7fd964385ee96b8e2447e2d0e9fd8decad30000000000000000000000000000000000000000000000000030927f74c9de0000",
         "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
       },
       {
         "type": "CALL",

但是當我從存檔節點查詢該塊的餘額時,它只顯示0x13d7adaac0a4940f,小於0x30927f74c9de0000。我在 Golang 中的程式碼:

   client, _ := ethclient.Dial("wss://archive_node_url")

   // token address
   MstAddress := common.HexToAddress("0xe7af3fcc9cb79243f76947402117d98918bd88ea")
   blockNum := big.NewInt(17453505)

   userAddress := common.HexToAddress("0x9b57b60f14fea2b9889f203ed29db879060147dc")

   mst, _ := erc20.NewErc20(MstAddress, client)
   balance, _ := mst.BalanceOf(&bind.CallOpts{
       BlockNumber: blockNum,
   }, userAddress)

   fmt.Println(balance)

我想也許使用者在同一個區塊發送兩個交易,首先發送一些令牌給它,然後鑄幣。但我檢查了那個區塊號,似乎只有使用者發送了一筆交易。

我想念什麼?

您正在查詢執行交易的區塊,因此您將在狀態更改後獲得金額。

如果要檢查以前的狀態,請查詢塊 17453504。

引用自:https://ethereum.stackexchange.com/questions/127393