skka3134

skka3134

email
telegram

Chainlink Automation

Execute one or more functions of the contract automatically according to a fixed time.

  1. Deploy a contract and obtain the address and ABI
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

contract erc20 is Initializable, ERC20Upgradeable, OwnableUpgradeable {
    using SafeERC20Upgradeable for IERC20Upgradeable;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }
    address erc721;
    function initialize() initializer public {
        __ERC20_init("ZombineCoin", "ZTC");
        __Ownable_init();
    }
    function setErc721(address erc721_)public{
        erc721=erc721_;
    }

    function mint(uint second) public  {
        _mint(msg.sender, 100*1e18*second);
    }
    function balance()public view returns(uint256){
        return balanceOf(msg.sender);
    }
    function approveMint()public{
        approve(erc721,100000*1e18);
    }
}
  1. Open Chainlink Automation https://automation.chain.link/goerli
    Select Trigger as time-based and fill in the contract address
    image
  2. Select the function name to be automatically executed and fill in the parameters
    image
  3. Select the frequency of execution
    image
    This is a cron expression that can be converted using a tool
    http://cron.ciding.cc/
    image
  4. Give it a name and deposit some link tokens
    image
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.