Tengo problemas para implementar mi contrato inteligente en la red ropsten usando infura y truffle recibo un error que dice
"var sig = secp256k1.sign(msgHash, privateKey);
^
TypeError: private key should be a Buffer"
Puede encontrar cómo implementar un contrato usando truffle e infura como se explica en la documentación de truffle
Copié el código de implementación que ya poseía a continuación,
// 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
}
}
};
Espero que te funcione a ti también
contract myContract is ERC20Interface { .. }
Entonces solo necesita incluir myContract en su archivo 2_deploy_contracts.jsDebe usar la dirección 'de' en minúsculas al implementar el contrato para probar la red para evitar este error.
secp256k1.sign
no acepta un parámetro from.Estoy de acuerdo con Ismael diciendo que la función sepc256k1.sign no necesitará del parámetro. funcionó para mí sin declaración de claves privadas y desde el parámetro
Nikita Fuchs
ismael
const privateKey = Buffer.from("ab1a..", "hex");