1

I am trying to invoke a Chainlink.Request method of one contract in another smartContract :

The farmContract.createFarm(.....) method makes a request to ExternalAdapter using Chainlink.Request and it's working fine independently when invoked by farmContract. But when using this method in another smartContract (NFTMinter.sol ), it says execution reverted.

If I comment the farmContract.createFram(tokenId) , the minting works fine. How do I invoke this createFarm method in this other contract method mintNFT(....).

Please help

function mintNFT(
        uint256 orderId,
        uint256 productId,
        address newOwner
    ) public onlyOwner {

        _tokenIdCounter.increment();
        uint256 tokenId = _tokenIdCounter.current();


        farmContract.createFarm(tokenId);

        // Transfer ownership of the product to the NFT minter contract
        productContract.transferProductOwnership(productId, address(this));


        _safeMint(newOwner, tokenId);
        _setTokenURI(tokenId, TOKEN_URI);
    }
1
  • Can you provide more code of the contract? It is likely the error is inside createFarm, but you haven't provided the source code, so the error could be anything.
    – Ismael
    Aug 7, 2023 at 1:00

1 Answer 1

0

If the function createFarm is in another smart contract, the Chainlink request is sent by another smart contract instead of the original one. That means msg.sender in the Chainlink operator contract is another smart contract's address rather than your consumer contract.

Because every time you send Chainlink requests, the contract has to pay the fee to Chainlink Oracle to fulfill the result. You have to make sure the contract that sends requests has enough ERC-677 LINK tokens in balance. For more details about request mode, please check the document.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.