I am having trouble deploying my smart contract to the ropsten network using infura and truffle am getting error that says

"var sig = secp256k1.sign(msgHash, privateKey);
TypeError: private key should be a Buffer"
  • 3
    can you share some code / link of a tutorial you used ?
    – n1cK
    Commented Jun 27, 2018 at 9:24
  • It appears you are passing an incorrect format for privateKey. If you have the hexadecimal private key you should pass as raw bytes instead const privateKey = Buffer.from("ab1a..", "hex");
    – Ismael
    Commented Jun 30, 2018 at 20:02

3 Answers 3


You can find how to deploy a contract using truffle and infura as it is explained truffle documentation

I copied the deployment code that I already owned below,

// Allows us to use ES6 in our migrations and tests.

const HDWalletProvider = require("truffle-hdwallet-provider-privkey");

const privateKey = "PRIVATEKEYADDRESS"; // private keys

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "",
      port: 8545,
      network_id: "*" // Match any network id
    rinkeby: {
      provider: () => {
        return new HDWalletProvider(privateKey, "https://rinkeby.infura.io/INFURAAPIKEY")
      network_id: 4

Hope it works for you as well

  • Mehmet Dogan Thanks for the help but am still getting another error it outputs Error encountered, bailing. Network state unknown. Review successful transactions manually. insufficient funds for gas * price + value
    – daniel
    Commented Jun 28, 2018 at 8:03
  • You share little with us and want to get full answer. But as far I know, this error is encountered when you try to deploy an Interface which includes unimplemented functions like ERC20Interface. Assuming that you try to deploy a contract named myContract contract myContract is ERC20Interface { .. } Then you just need to include myContract in your 2_deploy_contracts.js file Commented Jun 28, 2018 at 17:58

You have to use 'from' address in lower case while deploying the contract to test network inorder to avoid this error.

  • Your answer is unrelated to the question asked.
    – Ismael
    Commented Dec 6, 2018 at 21:16
  • Give a try. Actually, it worked for me and hence I responded!! Commented Dec 7, 2018 at 15:45
  • The function used secp256k1.sign doesn't accept a from parameter.
    – Ismael
    Commented Dec 7, 2018 at 19:45
  • If you are deploying your contract like this for example: SampleContract.new(abcd, {from: '0xAD123EFG456...'}).then(function(){}); then the from address should be in small letters like SampleContract.new(abcd, {from: '0xad123efg456...'}).then(function(){}); Commented Dec 8, 2018 at 12:28

Agree with Ismael saying the function sepc256k1.sign won't need from parameter. worked for me without private keys declaration and from parameter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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