Solidity

為什麼我的內部 txns 在我的交易中失敗了?

  • August 15, 2021

我已將鍊鍊接警報作業部署到 bsc 測試網上的預言機。我試圖在我的智能合約中的設定時間將代幣從一個地址轉移到另一個地址,交易似乎成功,但內部 txns 失敗。

這是失敗的交易

oracle 上的作業顯示傳入的事務已成功完成。

呼叫預言機的合約函式:

   function requestAlarmClock(uint256 durationInSeconds) public returns (bytes32 requestId) 
{
   Chainlink.Request memory request = buildChainlinkRequest(_jobId, address(this), this.fulfillAlarm.selector);
   // This will return in 90 seconds
   request.addUint("until", block.timestamp + durationInSeconds);
   return sendChainlinkRequestTo(_oracle, request, oraclePayment);
}

/**
* Receive the response in the form of uint256
*/ 
function fulfillAlarm(bytes32 _requestId, uint256 _volume) public recordChainlinkFulfillment(_requestId)
{

   token.transferFrom(owner, _reciver, 2e18);
}

該合約由 LINK 資助,因為它能夠支付預言機價格。我沒有註意到甲骨文方面的任何問題。預言機合約也由 LINK 資助。預言機合約是0x46cC5EbBe7DA04b45C0e40c061eD2beD20ca7755,這個合約的來源在這裡

交易跟踪0xFcABC46b..來看,當合約試圖轉移 RGP 代幣 ( 0x9f0227A2..)0x2289Bc37..時,它會失敗,transferFrom但所有者尚未批准它們。

{
 "type": "CALL",
 "from": "0xdd4b35fb5efe3975a937ca9cab81ba17f3b9208e",
 "to": "0x46cc5ebbe7da04b45c0e40c061ed2bed20ca7755",
 "value": "0x0",
 "gas": "0x748cc",
 "gasUsed": "0x15e2b",
 "input": "0x4ab0d190934d8bb17ebb8000127b45f1c53c18a0829f4819d58670191bbae16341cd4ea8000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000fcabc46bfc565f708972332d71124c073ba0084d01e13b510000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000611384520000000000000000000000000000000000000000000000000000000000000000",
 "output": "0x0000000000000000000000000000000000000000000000000000000000000000",
 "time": "22.9388ms",
 "calls": [
   {
     "type": "CALL",
     "from": "0x46cc5ebbe7da04b45c0e40c061ed2bed20ca7755",
     "to": "0xfcabc46bfc565f708972332d71124c073ba0084d",
     "value": "0x0",
     "gas": "0x6ef38",
     "gasUsed": "0x1206d",
     "input": "0x01e13b51934d8bb17ebb8000127b45f1c53c18a0829f4819d58670191bbae16341cd4ea80000000000000000000000000000000000000000000000000000000000000000",
     "error": "execution reverted",
     "calls": [
       {
         "type": "CALL",
         "from": "0xfcabc46bfc565f708972332d71124c073ba0084d",
         "to": "0x9f0227a21987c1ffab1785ba3eba60578ec1501b",
         "value": "0x0",
         "gas": "0x6a111",
         "gasUsed": "0xed01",
         "input": "0x23b872dd0000000000000000000000002289bc372bc6a46dd3ebc070fc5b7b7a49597a4e000000000000000000000000d6bc7f57755a4dece5c863794c7f37718d10064a0000000000000000000000000000000000000000000000001bc16d674ec80000",
         "error": "execution reverted"
       }
     ]
   }
 ]
}

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