Contract deployment failed with error: Cannot deploy a new contract via the GSN

This is my ropsen config

require('dotenv').config();
const { GSNProvider } = require("@openzeppelin/gsn-provider");

    module.exports = {
      // See <http://truffleframework.com/docs/advanced/configuration>
      // to customize your Truffle configuration!
      networks: {
        ganache: {
          provider() {
            return new GSNProvider(`${process.env.GANACHE}`, { signKey: `${process.env.METAMASK_KEY}`, useGSN: true })
          },
          network_id: '*', // Match any network id
          gas: 70000000, // Block Gas Limit same as latest on Mainnet https://ethstats.net/
          gasPrice: 1000000000
        },
        geth: {
          host: 'localhost',
          port: 8545,
          network_id: '*',
          gas: 4612388,
          gasPrice: 100000000
        },
        ropsten: {
          provider() {
            return new GSNProvider(`${process.env.INFURA_ROPSTEN}`, { signKey: `${process.env.METAMASK_KEY}`, useGSN: true })
            // return new HDWalletProvider(`${process.env.METAMASK_KEY}`, `${process.env.INFURA_ROPSTEN}`, 0, 5)
          },
          // from: `${process.env.METAMASK_ADDRESS}`,
          network_id: 3,
          gas: 8000000
        },
        rinkleby: {
          provider() {
            return new GSNProvider(`${process.env.INFURA_ROPSTEN}`, { signKey: `${process.env.METAMASK_KEY}`, useGSN: true })
          },
          // from: `${process.env.METAMASK_ADDRESS}`,
          network_id: 4,
          gas: 8000000
        }
      },
      compilers: {
        solc: {
          version: '0.5.9',
        }
      },
    };

And this is my deployment code

    const { scripts, ConfigManager } = require('@openzeppelin/cli');

    const { add, push, create } = scripts;

    async function deploy(options) {
      add({ contractsData: [{ name: 'ANO', alias: 'ANO' }] });
      await push(options);
      await create(Object.assign({ contractAlias: 'ANO' }, options));
    }

    module.exports = (deployer, networkName, accounts) => {
      deployer.then(async () => {
        const { network, txParams } = await ConfigManager.initNetworkConfiguration({ network: networkName })
        await deploy({ network, txParams })
      })
    }

when i try deploying with oz create --network ropsten ANO --init initialize
I get
✖ Validating and deploying contract ANO ANO deployment failed with error: Cannot deploy a new contract via the GSN
No other errors

1 Like

Hi @Dike_Jude,

Welcome to the community :wave:

Could you provide more details on what you are trying to do?

The error is from the GSNProvider, and as per the error we can’t deploy a new contract via the GSN:

If you haven’t already, I would look at the documentation on Connecting to Public Test Networks

Also, when using the CLI, we don’t need a deployment script.

Hi @Dike_Jude,

Checking to see if the above resolved your question?

Let me know if I can help.

Hi @abcoathup,
Yes it did, I thought I could deploy with GSNProvider, now I understand deploying should be with a provider like HDWalletProvider then connecting to the deployed instance with GSNProvider.
Thanks for your speedy reply

1 Like

Hi @Dike_Jude,

Let me know if you have any questions. Feel free to ask all the questions that you need.