0

I am having an issue migrating a contract using Oraclize API to Ganache from Truffle.

However, everything is working fine when running the contract from Remix IDE via MetaMask. As I want to write the frontend of the dapp, how to do that without migrating the contract into Ganache from Truffle?

1 Answer 1

1

In order to use contract you can use web3js only. Create instance of contract

var myContract = new web3.eth.Contract(<ABI>, '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe');

Take a look the documentation https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html

4
  • Am I understanding it correctly, that I need to first deploy the contract to Ganache from Remix, than copy the ABI from Remix to my a JS file and then import it to the var MyContract?
    – Ruham
    Commented Oct 20, 2018 at 10:56
  • 1
    yes. deploy -> copy ABI and address -> put in dapp -> instantiate contract -> communicate with the contract
    – Aquila
    Commented Oct 20, 2018 at 11:02
  • Do you know how does this work in React? Do I have to instantiate this once when the component will mount? And is that the address of the contract owner?
    – Ruham
    Commented Oct 21, 2018 at 11:56
  • You can instantiate in didMount event or globally. That address is contract address.
    – Aquila
    Commented Oct 21, 2018 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.