Forked MainNet with Ganache-ClI

wrote script to interact with on-chain DAI contract to send some Dai to account

Unlocked the DAI contract

const Web3 = require('web3');
const daiAbi = require('/Users/GreyShadow/inbox/ganache-cli.Fork/daiABI.js');

const recipientAddress = "0x1418D9353E655d277009E08aD882442B6e23F07D";
const unlockedAddress = "0xd4405F0704621DBe9d4dEA60E128E0C3b26bddbD";
const daiAdress = "0x6B175474E89094C44Da98b954EedeAC495271d0F";
const web3 = new Web3(`http://localhost:8545`);
const dai = new web3.eth.Contract(

async function run() {
  let unlockedBalance, recipientBalance;
  ([unlockedBalance, recipientBalance] = await Promise.all
        .call (),
    console.log('Balance unlocked: ${unlockedBalance}');
    console.log('Balance recipient: ${recipientBalance}');

    await dai.methods
      .transfer(recipientAddress, 1000)
      .send({from: unlockedAddress});

      ([unlockedBalance, recipientBalance] = await Promise.all ([
      console.log('Balance unlcoked: ${unlockedBalance}');
      console.log('Balance recipient: ${recipientBalance}');
run ();

when running node script.js following error is shown

        throw errors.ContractMissingABIError();

Error: You must provide the json interface of the contract when instantiating a contract object.

ABI is in that directory and should be required/recognized.

Any help would be much appreciated


  • "ABI is in that directory and should be required/recognized" - that's in your directory, not ours! Please open that file and make sure that it exports a proper ABI object. If you're not sure whether or not it does, then please post a short version of its contents as part of your question. – goodvibration Jan 7 at 17:58
  • By the way, ABI objects are usually given in a JSON file, which you should fs.readFileSync and then JSON.parse (in opposed to requiring a JS file as you seem to be doing). – goodvibration Jan 7 at 17:59
  • But since you've placed that ABI object in a JS file, you must module.exports this object inside that JS file in order to be able to require it. – goodvibration Jan 7 at 18:00
  • If you just copied it from a JSON file into a JS file, then note that it doesn't "magically" turn into JS code, and neither will requiring that file turn it into JS code. You need to do that yourself (as I explained above, declare it as an object in that file, and then module.exports it). – goodvibration Jan 7 at 18:05
  • Hey goodvibration. I get where youre coming from, however not quite sure on how to implement it. Something like this? ``` const daiABI = artifacts.require("daiABI"); module.exports = function (deployer) { deployer.deploy(daiABI); };```` – GreyShadow94 Jan 7 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.