0

I wanna make a hybrid smart contract where I have a function mint() . I want to call that function on a period of 24 hours. And I am thinking of using ChainLink's Time based automation. But I have a question, should the mint function be public to trigger it ? Can I make the function private and still call it ? I wanted to call the function privately by ChainLink's Time based automation based on some conditions. Can I do that ?

For example:

pragma solidity ^0.8.19;

contract Count {
    address public owner;

    constructor(){
        owner = msg.sender;
    }

    modifier onlyOwner(){
        require(msg.sender == owner,"Not owner");
        _;
    }
    uint256 public counted = 0;

    function countPrivate() private onlyOwner{
        counted += 1;
    }
    function countInternal() internal onlyOwner{
        counted += 1;
    }
    function countPublic() public onlyOwner{
        counted += 1;
    }
}

On this contract, I can only trigger the countPublic() function (someone told me to use onlyOwner modifier so that it may work, it will work if I remove the modifier but still it will be public and anyone can call it). But it dosen't seem to work. I want just chainlink triggers can call a function in my contract that is not accessible by others. How can I achieve it ?

Created triggering but doesn't work: Created triggering but doesn't work

1

1 Answer 1

0

It is intuitive to check if the msg.sender is the Chainlink Node but the address keeps changing.

Chainlink Documentation says: We recommend that you revalidate the conditions and data in performUpkeep before work is performed. We understand you might want to add a require statement, but then recommend that you make the Automation Registry address configurable otherwise you will need to deploy a new contract when the Registry address changes. If you add a require statement to performUpkeep you will have to update the Registry Address in your contract when the Registry Address changes. We also recommend that the owner can always call performUpkeep. Reference: https://docs.chain.link/chainlink-automation/faqs

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.