Execute one or more functions of the contract automatically according to a fixed time.
- 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);
}
}
- Open Chainlink Automation https://automation.chain.link/goerli
Select Trigger as time-based and fill in the contract address
- Select the function name to be automatically executed and fill in the parameters
- Select the frequency of execution
This is a cron expression that can be converted using a tool
http://cron.ciding.cc/
- Give it a name and deposit some link tokens