From 03ddc1d75f30f90baa4df961408a553b32835c43 Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Wed, 20 Nov 2024 19:25:33 +0700 Subject: [PATCH] Create contractInteraction.js --- .../BlockchainIntegration/contractInteraction.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 dapps-builder/src/components/BlockchainIntegration/contractInteraction.js diff --git a/dapps-builder/src/components/BlockchainIntegration/contractInteraction.js b/dapps-builder/src/components/BlockchainIntegration/contractInteraction.js new file mode 100644 index 000000000..8a3bb36e1 --- /dev/null +++ b/dapps-builder/src/components/BlockchainIntegration/contractInteraction.js @@ -0,0 +1,14 @@ +import web3 from './web3'; + +export const getContractInstance = (abi, address) => { + return new web3.eth.Contract(abi, address); +}; + +```javascript +export const callContractMethod = async (contract, method, args) => { + return await contract.methods[method](...args).call(); +}; + +export const sendTransaction = async (contract, method, args, from) => { + return await contract.methods[method](...args).send({ from }); +};