const Input = artifacts.require("Input");
const Register = artifacts.require("Register");

module.exports = function (deployer) {
  deployer.deploy(Input, "test_name")
    let instance = await Input.deployed();
    let name = instance.name();
    deployer.deploy(Register, name)

Tried using this during migration to get a public string variable from the first contract as the constructor argument of the second contract.

There're no errors but the second contract is not getting deployed...

please kindly answer this anyone.

  • so what is the return value from the deploying transaction when you do a debug.traceTransaction() of the hash of the second transaction????
    – Nulik
    Jul 24, 2021 at 14:12
  • how do you know the second contract is not deployed ? can you put a log after the second contract is deployed in a .then callback function ? Jul 24, 2021 at 20:40

1 Answer 1


The problem is that you cannot use Input.deployed() inside an script that deploys Input.

A workaround is to create an instance at Input.address, e.g. await Input.at(Input.address):

module.exports = function (deployer) {
  deployer.deploy(Input, "test_name").then(async () => {
    let instance = await Input.at(Input.address)
    let name = await instance.name()
    deployer.deploy(Register, name)
  • thanx a lot bro!
    – Ransika
    Jul 27, 2021 at 4:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.