I need to send a state-changing transaction to a Web3 contract object in my Truffle tests, which is hitting a fork of Kovan in my local ganache chain (ganache-cli --fork https://kovan.infura.io/v3/[api_key]@latest).

The contract I'm sending a transaction to is a Web3 contract object of an already-deployed contract on Kovan.

const theirContractABI = require("./abi/TheirContract");
const theirContractAddress = "0x123456789...";
const theirContract = new web3.eth.Contract(theirContractABI, theirContractAddress);

contract("MyContract", accounts => {
   it("can update a TheirContract property", async () => {
      await theirContract.methods.someFunction().send({ from: accounts[0] });
      assert(some condition);

When I run this specific test, all I get is Error: Returned error: VM Exception while processing transaction: revert, and it's not produced by a falsified require statement. So, I tried using @0x/sol-trace. When I run yarn trace, I get

error InitializableAdminUpgradeabilityProxy.sol:3:1: ParserError: Source "/Users/slider/Desktop/myProject/node_modules/@openzeppelin/upgrades/contracts/upgradeability/BaseAdminUpgradeabilityProxy.sol" not found: File import callback not supported

import './BaseAdminUpgradeabilityProxy.sol';    


error InitializableAdminUpgradeabilityProxy.sol:4:1: ParserError: Source "/Users/slider/Desktop/myProject/node_modules/@openzeppelin/upgrades/contracts/upgradeability/InitializableUpgradeabilityProxy.sol" not found: File import callback not supported

import './InitializableUpgradeabilityProxy.sol';    

TheirContract imports @openzeppelin/upgrades/contracts/upgradeability/InitializableAdminUpgradeabilityProxy.sol, but I have the @openzeppelin/upgrades package installed, and BaseAdminUpgradeabilityProxy.sol & InitializableUpgradeabilityProxy.sol are indeed located in the same file within node_modules as InitializableAdminUpgradeabilityProxy.sol.

enter image description here

So, I'm fairly unsure of where the issue stems from and how to resolve it. Would greatly appreciate a point in the right direction.

  • As I've already explained in an answer to a previous question of yours, Truffle's logical contract object is different from Web3's logical contract object. So you should avoid using the latter within your Truffle tests. Commented Jun 5, 2020 at 8:09
  • I'm able to use the Web3 contract method with an ERC20 contract and change an address balance in my Truffle tests. Is there a recommended way of Truffle-izing an already-deployed contract, or do I need to copy+paste the contract and all of its dependencies into their own files?
    – slider
    Commented Jun 5, 2020 at 8:20
  • Also, I'm still curious as to the underlying issue, whether it's related to sending a transaction to a Web3 contract object or not...
    – slider
    Commented Jun 5, 2020 at 8:22
  • Truffle-izing an already-deployed contract: const myContract = artifacts.require("MyContract").at(myContractAddress);. Commented Jun 5, 2020 at 8:33
  • I'm trying to Truffle-ize someone else's contract, say MakerDAO. I could get its state by forking mainnet or Kovan in ganache-cli, but how would I reference it in my tests? Grab the contract code and copy+paste into its own file? There has to be a better way.
    – slider
    Commented Jun 5, 2020 at 8:36

1 Answer 1


Turns out, all I had to do was specify a gasLimit in my send() method!

From this:

await theirContract.methods.someFunction().send({ from: accounts[0] });

To this:

await theirContract.methods.someFunction().send({ from: accounts[0], gasLimit: 800000 });

And I can use the Web3 contract object to do so, which is the easiest way to reference an already-deployed contract that I'm currently aware of, because you can just grab the ABI and address from EtherScan, and fork mainnet/Kovan/etc to your local ganache chain!

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.