From 21a494bba66f085a51b98b9d9c78b54eebb85b80 Mon Sep 17 00:00:00 2001 From: Aayush Gupta <60979345+AAYUSH-GUPTA-coder@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:24:53 +0530 Subject: [PATCH] Create store-data.js --- tasks/store-data.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tasks/store-data.js diff --git a/tasks/store-data.js b/tasks/store-data.js new file mode 100644 index 0000000..29b3169 --- /dev/null +++ b/tasks/store-data.js @@ -0,0 +1,32 @@ +task( + "store-data", + "Stores data on an Edge-UR Node, and Filecoin" + ) + .addParam("contract", "The address of the deal client solidity") + .addParam("uri", "The uri of the data to store") + .setAction(async (taskArgs) => { + //store taskargs as useable variables + //convert piece CID string to hex bytes + const contractAddr = taskArgs.contract + const uri = taskArgs.uri + + const networkId = network.name + console.log("Making deal proposal on network", networkId) + + //create a new wallet instance + const wallet = new ethers.Wallet(network.config.accounts[0], ethers.provider) + + //create a EdgeURContract contract factory + const EdgeURContract = await ethers.getContractFactory("EdgeURContract", wallet) + //create a EdgeURContract contract instance + //this is what you will call to interact with the deployed contract + const edgeURContract = await EdgeURContract.attach(contractAddr) + + //send a transaction to call makeDealProposal() method + transaction = await edgeURContract.StoreURI(uri) + transactionReceipt = await transaction.wait() + + //listen for DealProposalCreate event + //const event = transactionReceipt.events[0].topics[1] + console.log("Complete! Event Emitted. ProposalId is:", transactionReceipt) + })