const web3 = new Web3(new Web3.providers.HttpProvider(process.env.MUMBAI_ALCHEMY_URL));
//create contract instances for each of these
const host = new web3.eth.Contract(hostABI, hostAddress);
const cfa = new web3.eth.Contract(cfaABI, cfaAddress);
const tradeableCashflow = new web3.eth.Contract(tradeableCashflowABI, tradeableCashflowAddress);
const fDAIx = "0x5D8B4C2554aeB7e86F387B4d6c00Ac33499Ed01f"
const userData = web3.eth.abi.encodeParameter('string', 'HODL ETH');
const nonce = await web3.eth.getTransactionCount(_sender, 'latest'); // nonce starts counting from 0
//create flow by calling host directly in this function
//create flow from sender to tradeable cashflow address
//pass in userData to the flow as a parameter
async function updateFlow() {
let cfaTx = (await cfa.methods
tradeableCashflowAddress,
let txData = (await host.methods.callAgreement(
let signedTx = await web3.eth.accounts.signTransaction(tx, process.env.MUMBAI_DEPLOYER_PRIV_KEY);
await web3.eth.sendSignedTransaction(signedTx.rawTransaction, function(error, hash) {
console.log("π The hash of your transaction is: ", hash, "\n Check Alchemy's Mempool to view the status of your transaction!");
console.log("βSomething went wrong while submitting your transaction:", error)
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
.then(() => process.exit(0))