【问题标题】:How to fund Chainlink smart contract with other contract?如何用其他合约为 Chainlink 智能合约注资?
【发布时间】:2021-06-17 19:41:59
【问题描述】:

我正在尝试使用 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。我究竟做错了什么?我如何让它发挥作用?

【问题讨论】:

    标签: ethereum solidity smartcontracts erc20 chainlink


    【解决方案1】:

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

    You can read the Chainlink documentation for more information.

    看起来你正在使用混音。

    1. 获取合约地址。
    2. 将其粘贴到您的 Metamask 中

    3. 发送您的合同 LINK

    您会收到一些确认通知。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-06
      • 2021-11-15
      • 2021-09-03
      • 1970-01-01
      • 2023-01-25
      • 2022-08-12
      • 2017-08-19
      • 2021-03-12
      相关资源
      最近更新 更多