Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
How to add private keys to deploy a smart contract to Roptsen?

I am trying to deploy a smart contract to the Ropsten test net.

I have tried to add the private keys mnemonic to a .secret file but get the following error below when running in the terminal truffle migrate --network ropsten

Error: Private key does not satisfy the curve requirements (ie. it is invalid)

The infura api key works by importing it with dot env.

The mnemonic private key is from a metamask wallet.

This is what is in the truffle.config file now:

require('babel-polyfill');
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
const MNEMONIC = './.secret';
const infuraKey = process.env.INFURA_API_KEY


module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },

    ropsten: {
      provider: () => new HDWalletProvider(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 )
    }
  },
  contracts_directory: './src/contracts/',
  contracts_build_directory: './src/abis/',
  compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Someone else encountered this issue here

There was a suggestion to use Buffer.from, i.e. Buffer.from('<PRIVATE_KEY>', 'hex') to convert your private key to a Buffer first.

Could try using below:

const privateKey = Buffer.from('PRIVATEKEYFROMMETAMASK', 'hex');
const provider = new HDWalletProvider(privateKey, "https://ropsten.infura.io/v3/INFURATOKEN");
const web3 = new Web3(provider);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!