You can read the blog at: https://medium.com/@javier_donoso/gelato-v2-superfluid-eb13166ac414 and see the walkthrough video: https://www.youtube.com/watch?v=OphQ2BdXJDQ&t=1s
A super simple foundry/Hardhat hybrid project which utilizes Superfluid's CFA Access Control List feature and Gelato to close a flow at a predetermined time in the future.
In order to run this project, you need to have the following dependencies installed on your computer:
To set up the project run the following command:
yarn // installing the node_modules
yarn compile // compiling with hardhat the project
Copy the .env.template--> and enter your private jey, infura Id and Etherscan if required We will open a second terminal and run:
yarn fork // fork the network into a local hardhat node
Contract deploy:
yarn deploy localhost
The console will log something like:
Close Sream deployed succsessfully at: 0xCC7FA88DB7df720EA72872ad7C19fd85026047d9
We will copy the deployed address into the './scripts/Helpers.ts' so it will be available later.
export const CloseStreamAddress = "0xCC7FA88DB7df720EA72872ad7C19fd85026047d9";
We will now start a stream
yarn startStream localhost // in scripts/startStream.ts
Authorize our smart contract to stop the stream
yarn authorizeControl localhost // in scripts/authorizeControl.ts
Create the task
yarn createTaskStopStream localhost // in scripts/createTaskStopStream.ts
We are goig to mock the Gelato execution, so we will need exactly the start time of the task, when deplpoying on goerli we wont require it as the executiojn will be done by the Gelato executors
eth_sendTransaction
Contract call: CloseStream#createCloseStreamTask
Transaction: 0x079cd1d093a7b9b093df487af947088b7502637d2a55592c9fd4cafba135f2e3
From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
To: 0xcc7fa88db7df720ea72872ad7c19fd85026047d9
Value: 0 ETH
Gas used: 202686 of 202686
Block #7850260: 0xb649932d9314e7d02697e63ce31fccde93580b0cb6c3db7c5fb853fb5b74b2cf
console.log:
1666974177
We copy the timestamp '1666974177' into the stopStreamscript and we mock the gelato execution:
yarn stopStream localhost
Contract deploy:
yarn deploy goerli
The console will log something like:
Close Sream deployed succsessfully at: 0xCC7FA88DB7df720EA72872ad7C19fd85026047d9
We will verify our contract to interact later with etherscan
yarn verify goerli // in scripts/verify.ts
We will copy the deployed address into the './scripts/Helpers.ts' so it will be available later.
export const CloseStreamAddress = "0xCC7FA88DB7df720EA72872ad7C19fd85026047d9";
We will now start a stream
yarn startStream goerli // in scripts/startStream.ts
Authorize our smart contract to stop the stream
yarn authorizeControl goerli // in scripts/authorizeControl.ts
Create the task
yarn createTaskStopStream goerli // in scripts/createTaskStopStream.ts
Our contract is verified here Gelato task logs can be found here
For the time being we will use to check the status of our task at:
https://ops-interface-vue-git-feature-search-gelato.vercel.app/task/{{taskId}}?chainId=5