Chainlink

為什麼我在 Remix 上會出現 Gas Estimation 錯誤?我有很多 ETH 和 LINK

  • March 21, 2022

我不斷收到此錯誤,無法弄清楚原因。我的 metamask 賬戶中有 1.4 ETH 和 110 LINK。我已連接到 Kovan 測試網。任何幫助將非常感激。

錯誤:氣體估計錯誤並顯示以下消息(見下文)。事務執行可能會失敗。是否要強制發送?由於異常,執行失敗。還原

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

contract CheckingThisOut is ChainlinkClient {
   using Chainlink for Chainlink.Request;

   address[] private subaddress;

   address private oracle;
   bytes32 private jobId;
   uint256 private fee;

   constructor() {
       setChainlinkToken(0xa36085F69e2889c224210F603D836748e7dC0088);
       //https://market.link/nodes/323602b9-3831-4f8d-a66b-3fb7531649eb/metrics?start=1640025302&end=1640630102
       //Linkpool
       oracle = 0x56dd6586DB0D08c6Ce7B2f2805af28616E082455;
       //https://market.link/jobs/d3d7cfc4-963e-4bc6-b94d-21bfe8d90aff
       jobId = "c128fbb0175442c8ba828040fdd1a25e";
       // 17 0s = 0.1 LINK
       // 18 0s = 1 LINK
       fee = 0.1 * 10 ** 18; // (Varies by network and job)
   }

   /**
    * Create a Chainlink request to retrieve API response, find the target
    * data, then multiply by 1000000000000000000 (to remove decimal places from data).
    */
   function requestSubscriptions() public returns (bytes32 requestId)
   {
       Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);

       // Set the URL to perform the GET request on
       request.add("get", "http://1423-104-243-59-126.ngrok.io/");


       request.add("path", "result");

       // Sends the request
       return sendChainlinkRequestTo(oracle, request, fee);
   }


   function fulfill(bytes32 _requestId, address[] memory _subaddress) public recordChainlinkFulfillment(_requestId)
   {
       subaddress = _subaddress;
   }
}

哇,我想通了。我在這上面花了 5 個小時,在我發布問題後,我再次觀看了相同的教程影片(第 10 次)。我從未將 LINK 發送到已部署的合約地址。我發送了一些連結,它起作用了。

@Chris 你能解釋一下你是怎麼做到的嗎?我的 Kovan 測試網中有 .27ETH 和 40 LINK。如何在我的程式碼中將連結發送到已部署的合約地址…

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.6 <0.9.0;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

contract FundMe {

   mapping (address => uint256) public addressToAmountFunded;
   
function fund() public payable {
   uint256 minimumUSD = 50 * 10 ** 18;
       require (getConversionRate (msg.value) >= minimumUSD, "You need to spend more ETH!");
           addressToAmountFunded[msg.sender] += msg.value;
   ///msg.sender and msg.value both in every contract call and transaction 
   //msg.sender is the sender and msg. value is how much they sent 
}
function getVersion () public view returns (uint256) {
   AggregatorV3Interface _priceFeed = AggregatorV3Interface (0x9326BFA02ADD2366b30bacB125260Af641031331);
       return _priceFeed.version();
}
function getPrice () public view returns (uint256) {
   AggregatorV3Interface _priceFeed = AggregatorV3Interface (0x9326BFA02ADD2366b30bacB125260Af641031331);
       (,int256 answer,,,) = _priceFeed.latestRoundData();
           return uint256 (answer);     
}
function withdraw () payable public {
   msg.sender.transfer(address(this).balance);
//this means current contract //whoever called the withdraw function (msg.sender) transfer them the money
}

}

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