Let's say I have these 2 contracts defined in the same solidity file.

contract Coin {
   string public name;
   constructor(string _name) public { 
      name = _name;
contract MetaCoin {
   Coin public coin;
   constructor(Coin _coin) public {
       coin = _coin;

Now I want to write a javascript migration in order to deploy so I tried the following

const coin = artifacts.require("Coin");
const meta = artifacts.require("Metacoin");

module.exports = async function (deployer, network, accounts) {

   await deployer.deploy(Coin,"diamond");
   const coin = await Coin.deployed();
   await deployer.deploy(MetaCoin, coin);

However my last line await deployer.deploy(MetaCoin, coin); causes an error since coin is not the correct thing to pass into the constructor of MetaCoin.

The error is pasted below

Error: while migrating Masterchef: invalid address (argument="address", value="[object Object]", code=INVALID_ARGUMENT, version=address/5.0.5) (argument="_Pcake", value="[object Object
]", code=INVALID_ARGUMENT, version=abi/5.0.7)

I read the following question but I don't think it applies to my case since I define the Coin type. Can a Solidity function accept an object from JS. For example, can addTenant(**Tenant tenantObj**) accept Tenant Object?

1 Answer 1


Turns out you can just pass in the address of Coin instead of the Coin abstraction.

I ended up using

   await deployer.deploy(MetaCoin, coin.address);

I'm not sure why that ended up working so if someone could explain, that would help a lot.

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.