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?