I'm writing my smart contract tests in JS and using Truffle. I want to test a specific function in my contract that requires a token address and contract address as parameters:

        address _asset, //address base token, like USDC
        address _payee,
        uint8 _dueDate,
        uint256 _amount,
        bytes calldata _paymentReference,
        address _cometAddress

When I just pass the mainnet USDC token address and mainnet Comet Address, the test errors out:

it("should be able to make an ERC20 payment", async () => {
    await instance.payInvoiceERC20(
      "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", //USDC mainnet token address
      accounts[8], //setting a payee
      10000000, //10 USDC, 6 decimals for USDC token
      "0x494e56332d32343034", //payment ref. in bytes
      "0xc3d688B66703497DAA19211EEdff47f25384cdc3" //Comet Address USDC mainnet

Error message: "exited with an error (status 0). Reason given: Address: call to non-contract."

From what I read online and SO answers from 2018-2019, I understand I need to somehow instantiate the ERC20 token contract (+ Comet contract). What is the best and fastest way?

1 Answer 1


The easiest solution is to make the USDC address configurable. Then you can deploy your own copy of the token in a testnet and use that address to simulate the payments.

  • Hi Ismael, thanks for your reply. Would you be able to give me an example? Concerning the Comet contract I'm sending funds to, do I need to deploy it as well? And how do I do that?
    – Piji
    Commented Apr 29, 2023 at 8:16
  • @Piji There isn't much to say, unless something specific is needed just create an ERC20 based on OpenZeppelin contracts.
    – Ismael
    Commented May 2, 2023 at 15:15

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.