Skip to main content
Formattings
Source Link
Achala Dissanayake
  • 5.8k
  • 15
  • 30
  • 38

In the frontend i just do this:

import MyContract fom './contracts/MyContract.json'; //truffle project dir web3 = new Web3(Web3.givenProvider); const myContractWeb3 = new web3.eth.contract(MyContract.abi, "0x00"); // and then call the function that i want to const functionThatIWantToUseFromSmartContract = async () =>{ const account = await window.ethereum.enable(); const accounts = account[0]; const gas = await myContractWeb3.methods.theFunction(args).estimateGas(); await myContractWeb3.methods.theFunction(args).send(); } 
import MyContract fom './contracts/MyContract.json'; //truffle project dir web3 = new Web3(Web3.givenProvider); const myContractWeb3 = new web3.eth.contract(MyContract.abi, "0x00"); // and then call the function that I want to const functionThatIWantToUseFromSmartContract = async () =>{ const account = await window.ethereum.enable(); const accounts = account[0]; const gas = await myContractWeb3.methods.theFunction(args).estimateGas(); await myContractWeb3.methods.theFunction(args).send(); } 

In the frontend i just do this:

import MyContract fom './contracts/MyContract.json'; //truffle project dir web3 = new Web3(Web3.givenProvider); const myContractWeb3 = new web3.eth.contract(MyContract.abi, "0x00"); // and then call the function that i want to const functionThatIWantToUseFromSmartContract = async () =>{ const account = await window.ethereum.enable(); const accounts = account[0]; const gas = await myContractWeb3.methods.theFunction(args).estimateGas(); await myContractWeb3.methods.theFunction(args).send(); } 

In the frontend i just do this:

import MyContract fom './contracts/MyContract.json'; //truffle project dir web3 = new Web3(Web3.givenProvider); const myContractWeb3 = new web3.eth.contract(MyContract.abi, "0x00"); // and then call the function that I want to const functionThatIWantToUseFromSmartContract = async () =>{ const account = await window.ethereum.enable(); const accounts = account[0]; const gas = await myContractWeb3.methods.theFunction(args).estimateGas(); await myContractWeb3.methods.theFunction(args).send(); } 
Source Link

In the frontend i just do this:

import MyContract fom './contracts/MyContract.json'; //truffle project dir web3 = new Web3(Web3.givenProvider); const myContractWeb3 = new web3.eth.contract(MyContract.abi, "0x00"); // and then call the function that i want to const functionThatIWantToUseFromSmartContract = async () =>{ const account = await window.ethereum.enable(); const accounts = account[0]; const gas = await myContractWeb3.methods.theFunction(args).estimateGas(); await myContractWeb3.methods.theFunction(args).send(); }