Problema: no puedo migrar (conectar) una cadena privada de ethereum en el servidor de la nube.
Resultados actuales
Will:dragon zhuangweiming$ truffle migrate --network development
Using network 'development'.
Running migration: 1_initial_migration.js
Could not connect to your Ethereum client. Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., "--rpc" option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle.js)
Ambiente
trufa.js
module.exports = {
networks: {
development: {
host: "47.92.53.158", //this is the IP of ethereum server running on cloud
port: 8545, //
network_id: "15", // test server.
from: "0xbe2c0def75c0257f1a9968d2d373febf849d6603", // account created on ethereum 47.92.53.158.
gas: 4712388, //default 4712388
gasPrice: 100000000000 //default 100000000000(100 Shannon)
}
}
};
1_migración_inicial.js
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
2_deploy_contratos.js
var Dragon = artifacts.require("./Dragon.sol");
module.exports = function(deployer) {
deployer.deploy(Dragon);
};
Probé el comando geth de la siguiente manera:
geth --networkid 15 --datadir data --rpc --rpcapi 'web3,eth,net' --rpccorsdomain '*' --rpcaddr 0.0.0.0 --rpcport 8545 --port 30303 console
En mi caso, funcionó después de modificar truffle.js.
Los pasos exactos fueron:
Al iniciar la red privada:
geth --datadir=mychaindata\ --nodiscover --rpc
mostró el puerto abierto en 8545 (no usé --rpccorsdomain allí porque la migración de trufas no funciona en ese momento)
En truffle.js cambió el puerto a 8545 y luego agregó un valor de gas:
port: 8545
gas: 3000000 // added because on truffle migrate, it showed exceed gas value error
Desbloqueé las cuentas y comencé el minero por separado, geth attach
luego probé truffle migrate
, la migración se completó con éxito.
Además, después de ejecutarlo npm run dev
, mostró un error de recuperación en el puerto 9545.
Modifiqué app.js cambiando el puerto a 8545. Actualizar la página mostró un error de origen cruzado, así que detuve la red y reinicié como:
geth --datadir=mychaindata\ --nodiscover --rpc --rpccorsdomain --unlock 0 --mine 1
¡Después de aceptar la contraseña, la red comenzó y todo funcionó bien!
No soy un experto en trufa/geth,... pero si despliegas un contrato en la red tienes que pagar gasolina por ello. Entonces, tal vez necesite desbloquear su cuenta de alguna manera.
Si este es el problema, puede intentar desbloquear la cuenta
0xbe2c0def75c0257f1a9968d2d373febf849d6603
como se describe aquí .
Espero eso ayude.
ismael
Will_Z