Cuando ejecuto el siguiente comando, no recibo ningún resultado:
truffle migrate --network ropsten
Esto es justo después de crear un nuevo proyecto usando truffle init
y creando un solo contrato.
Cuando ejecuto truffle develop
y ejecuto el comando de migración desde la consola, todo funciona bien.
Este es el contenido de mi archivo truffle.js:
var HDWalletProvider = require("truffle-hdwallet-provider");
var mnemonic = "my twelve word mnemonic......";
module.exports = {
networks: {
ropsten: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/xxxxxxxxxxxxx")
},
network_id: 3
},
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Estoy en Ubuntu 16.04 y la última versión de truffle 4.1.8.
(y sí, he financiado mi cuenta en Ropsten con Ether del grifo)
Así es como lo hago para implementar en Kovan, por ejemplo, cambiando el enlace de infura que puede implementar en cada red de prueba . Funciona para mí totalmente bien:
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require ('./compile'); //That files come from the compile.js you can see it below.
const provider = new HDWalletProvider(
'12 words mneumonic',
'https://kovan.infura.io/XXXXXXXXXXXX'
);
const web3 = new Web3(provider);
const deploy = async ()=> { //Create that function to use async & await
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account', accounts[0]);
const result = await new web3.eth.Contract(JSON.parse(interface))
.deploy({data: bytecode})
.send({ gas: '30000000', from: accounts[0]});
console.log('Contract deployed to', result.options.address);
console.log(interface);//We pass the ABI through the console to be able to use it to build the javascript object that emulates the contract on our react code.
};
deploy();
Aquí os dejo el compile.js por si lo necesitáis.
const path = require('path'); // Helps to find the path to the contract across whatever OS you are using form compile.js to xxx.sol files
const fs = require('fs'); // Load the FileSystem Module.
const solc = require('solc');
const contractPath = path.resolve(__dirname, 'contracts', 'Contracts_Remix.sol'); //Creation of cross SO's path.
const source = fs.readFileSync(contractPath, 'utf8');
//We compile the source code, of 1 single contract and showed the bytecode and the ABI by console to examine it.
console.log(solc.compile(source),1);
module.exports = solc.compile(source).contracts[':Your_contract_name'];
//We only call the contract we want to deploy.
¡Espero eso ayude!
Estaba teniendo el mismo problema, pero en mi caso, había configurado incorrectamente mi variable de entorno de punto final de infura en mi clave secreta en lugar de mi ID de proyecto. En caso de que alguien más lea esto, ¡asegúrese de que su punto final de infura sea correcto!
Al no llegar a ninguna parte con esto, parece que la migración se atasca en la primera parte:
> {
> "jsonrpc": "2.0",
> "id": 1,
> "method": "eth_accounts",
> "params": []
> }
Podría deberse a que estoy detrás de un proxy corporativo, pero no puedo saberlo por la salida. ¡Perplejo!
Estaba teniendo un problema similar y al bajar la versión del proveedor de hdwallet se resolvió el problema (truffle-hdwallet-provider de 1.0.7 a 1.0.6).
greg jeanmart
--verbose-rpc
para obtener algunos rastros de depuración. De lo contrario, si desea restablecer la compilación desde cero, intente--reset --compile-all
simbro
greg jeanmart
--reset --compile-all
?simbro
truffle compile --reset --compile-all
?greg jeanmart
truffle migrate --network ropsten --reset --compile-all --verbose-rpc
simbro
{ "jsonrpc": "2.0", "id": 1, "method": "eth_accounts", "params": [] }