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"
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityYou 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.
require('babel-register')
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: "127.0.0.1",
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
contract myContract is ERC20Interface { .. }
Then you just need to include myContract in your 2_deploy_contracts.js file
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.
Agree with Ismael saying the function sepc256k1.sign won't need from parameter. worked for me without private keys declaration and from parameter
const privateKey = Buffer.from("ab1a..", "hex");