Skip to content

Commit

Permalink
Create contractInteraction.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Nov 20, 2024
1 parent b01d778 commit 03ddc1d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 });
};

0 comments on commit 03ddc1d

Please sign in to comment.