如何用其他合约资助 Chainlink 智能合约?

问题描述

我正在尝试使用 LINK 代币为智能合约提供资金。我收到错误消息“VM 错误:revert。revert 交易已恢复到初始状态。注意:如果您发送价值并且您发送的价值应该小于您当前的余额,则调用函数应该是可支付的。将交易调试为获取更多信息。”我的代码很简单:

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

//Remix Imports
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/ChainlinkClient.sol";
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/vendor/Ownable.sol";
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/vendor/SafeMathChainlink.sol";
import "https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/interfaces/LinkTokenInterface.sol";
import "https://github.com/smartcontractkit/chainlink/blob/master/evm-contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

contract SimpleStorage {
  SimpleStorage2[] simpleStorage2s;

  function set() public payable returns(address) {
    SimpleStorage2 a = new SimpleStorage2();
    simpleStorage2s.push(a);

    LinkTokenInterface link = LinkTokenInterface(a.getChainlinkToken());
    link.transfer(address(a),100);
    
    return address(a);
  }

}

contract SimpleStorage2 is ChainlinkClient,Ownable {

  function getChainlinkToken() public view returns (address) {
         return chainlinkTokenAddress();
     }
}

solidity 编译器 0.6.12。我究竟做错了什么?我如何让它发挥作用?

解决方法

获取您部署的合约的地址,并将其发送 LINK。

You can read the Chainlink documentation for more information.

您好像在使用 remix。

  1. 获取您的合同地址。 enter image description here
  2. 将其粘贴到您的 Metamask 中

enter image description here 3. 发送您的合同链接

您会收到一些确认通知。