How to deploy on ropsten with zos? (deployment failed with error: Unknown address - unable to sign transaction for this address)

Hi @itinance

The from in your truffle-config.js is causing the issue.
The error is meant to explain that your from address is unknown
Unknown address - unable to sign transaction for this address:

https://www.trufflesuite.com/docs/truffle/reference/configuration#networks
from : From address used during migrations. Defaults to the first available account provided by your Ethereum client.

Without specifying a from the transaction will be sent using the first account generated by the mnemonic.
If the account doesn't have enough Ether you will get the error insufficient funds for gas * price + value

If you want to use an account other than the first account, you can specify the index to the account.

https://www.trufflesuite.com/tutorials/using-infura-custom-provider
Without any other arguments, the account in charge of migration will be the first one generated by the mnemonic. But if desired, you can pass in an argument to specify which account to use. As an example, to use the third account:

new HDWalletProvider(mnemonic, "https://ropsten.infura.io/v3/<INFURA_PROJECT_ID>", 2);

(Recall that the index is zero-based, so 2 is the third address.)


If you ever have issues deploying, I recommend deploying a simple contract to check your config, as deploying via Infura can silently fail if there is an issue with config. (I had an issue with my config today, and resolved by deploying a simple contract using truffle to Ropsten first)

truffle-config.js

require('dotenv').config();

const HDWalletProvider = require('truffle-hdwallet-provider');
const infuraKey = process.env.INFURA_API_KEY;

module.exports = {
  networks: {
    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },

    ropsten: {
        provider: () => new HDWalletProvider(process.env.DEV_MNEMONIC, "https://ropsten.infura.io/v3/" + infuraKey),
        network_id: 3,       // Ropsten's id
        gas: 5500000,        // Ropsten has a lower block limit than mainnet
        confirmations: 2,    // # of confs to wait between deployments. (default: 0)
        timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
        skipDryRun: true,     // Skip dry run before migrations? (default: false for public nets )
    },
  },
}

.env

INFURA_API_KEY="ENTER YOUR INFURA PROJECT ID"
DEV_MNEMONIC="ENTER YOUR 12 WORD SEED PHRASE"

I deployed and interacted with the contract using ZeppelinOS 2.4.0 interactive commands, following the Quick Start in the documentation

$ npx zos create
Nothing to compile, all contracts are up to date.
? Pick a contract to instantiate Counter
? Pick a network ropsten
✓ Contract Counter deployed
All contracts have been deployed
? Do you want to call a function on the instance after creating it? No
✓ Setting everything up to create contract instances
✓ Instance created at 0xc4De55D1d5c20fDf40c9A0D41CfC8A9245040d9b
0xc4De55D1d5c20fDf40c9A0D41CfC8A9245040d9b

If you are using ZeppelinOS without truffle (and hence you don't have a truffle-config.js) you use network.js for network configuration.

network.js

require('dotenv').config();

const HDWalletProvider = require('truffle-hdwallet-provider');
const infuraKey = process.env.INFURA_API_KEY;

module.exports = {
  networks: {
    development: {
      protocol: 'http',
      host: 'localhost',
      port: 8545,
      gas: 5000000,
      gasPrice: 5e9,
      networkId: '*',
    },
    ropsten: {
      provider: () => new HDWalletProvider(process.env.DEV_MNEMONIC, "https://ropsten.infura.io/v3/" + infuraKey),
      networkId: 3,       // Ropsten's id
    },
  },
};
1 Like