How to fund Chainlink smart contract with other contract?

Viewed 515

I'm trying to fund a smart contract with LINK tokens. I get an error "VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information." My code is simple:

// 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 compiler 0.6.12. What am I doing wrong? How do I get this to work?

1 Answers
Related