There are three ways to create Web3 Function Tasks:
- Using the UI
- Using the Automate-SDK
- Using a smart contract
This project demonstrates creating a Web3 Function task directly from a Smart Contract (3rd option).
This behaviour is ideal for factory contracts as everything takes place on-chain.
There are three ways to handle fee payment:
- Using 1Balance
- This will fund all tasks you create on any network
- Sync fee payment with native tokens in the target contract
- This will only fund tasks interacting with that one contract
- Sync fee payment with native tokens in the dedicated message sender
- This will fund all your tasks on that network
Oracle1Balance
fee payment using 1BalanceOracleSyncFee
fee payment using native tokens in the contract
Implementation is as simple as inheriting from AutomateTaskCreator
and calling _createTask
with the appropriate arguments.
If you'd like to use sync fee payment, ensure the contract is funded and then, in your automated function, transfer the fee using _getFeeDetails
and _transfer
.
Warning
Ensure this function is using the onlyDedicatedMsgSender
modifier, otherwise anyone will be able to call it and maliciously transfer a fee to themselves.
Web3 Function are currently in private beta.
In order to get access, please reach out to us here
Note
Ensure the contract itself is whitelisted and not the deployer (EOA)
- Install dependencies
yarn install
- Compile smart contracts
yarn run hardhat compile
- Edit
.env
cp .env.example .env
- Run unit tests
yarn run hardhat test