Ich habe tagelang damit gekämpft und ein paar Dinge gegoogelt, aber immer noch kein Glück. Hier ist mein Code für 2_deploy_contracts.js
:
const CoinCrowdsale = artifacts.require("./CoinCrowdsale.sol")
module.exports = function(deployer, network, accounts) {
return liveDeploy(deployer, accounts);
};
const duration = {
seconds: function(val) { return val},
minutes: function(val) { return val * this.seconds(60) },
hours: function(val) { return val * this.minutes(60) },
days: function(val) { return val * this.hours(24) },
weeks: function(val) { return val * this.days(7) },
years: function(val) { return val * this.days(365)}
};
function latestTime() {
return web3.eth.getBlock('latest').timestamp;
}
async function liveDeploy(deployer, accounts) {
const startTime = latestTime() + duration.seconds(1); // one second in the future
const endTime = startTime + (86400 * 30); // 30 days
const rate = new web3.BigNumber(1000);
const wallet = accounts[0];
return deployer.deploy(CoinCrowdsale, startTime, endTime, rate, wallet);
}
und hier die fehlermeldung:
➜ COIN git:(master) ✗ truffle deploy --network ropsten --reset
Using network 'ropsten'.
Running migration: 1_initial_migration.js
Replacing Migrations...
... 0x64f00774e5e7322d4a3d44dc0a1ef15962dc898750c7adbb2ebc3fe39872ee39
Migrations: 0x10c30744d4860f3ca714d52b07e7c864d32f5e01
Saving successful migration to network...
... 0x12637ca8c8dc5dde86831594b4b1084dad776d080523b2551a0e142d9bd5bdf7
Saving artifacts...
Running migration: 2_deploy_contracts.js
Saving successful migration to network...
(node:81173) UnhandledPromiseRejectionWarning: Error: Web3ProviderEngine does not support synchronous requests.
at ProviderError.ExtendableError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1)
at new ProviderError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/error.js:17:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:71:1
at WalletProvider.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:109:1)
at Object.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:209:1)
at RequestManager.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:58:1)
at Eth.send [as getBlock] (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:145:1)
at latestTime (/Users/glaksmono/Documents/COIN/migrations/2_deploy_contracts.js:17:19)
at liveDeploy (/Users/glaksmono/Documents/COIN/migrations/2_deploy_contracts.js:21:21)
at module.exports (/Users/glaksmono/Documents/COIN/migrations/2_deploy_contracts.js:4:10)
(node:81173) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:81173) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
... 0x1688c2faeb17b37432f524d18e125675234b5b68abde005b7245980e7c6d8f2a
Saving artifacts...
➜ COIN git:(master) ✗ truffle version
Truffle v4.0.6 (core: 4.0.6)
Solidity v0.4.19 (solc-js)
Gedanken?
Versuche es mit:
const CoinCrowdsale = artifacts.require("./CoinCrowdsale.sol")
module.exports = async function(deployer, network, accounts) {
return await liveDeploy(deployer, accounts);
};
const duration = {
seconds: function(val) { return val},
minutes: function(val) { return val * this.seconds(60) },
hours: function(val) { return val * this.minutes(60) },
days: function(val) { return val * this.hours(24) },
weeks: function(val) { return val * this.days(7) },
years: function(val) { return val * this.days(365)}
};
async function latestTime() {
const latestBlock = await web3.eth.getBlock('latest');
return latestBlock.timestamp;
}
async function liveDeploy(deployer, accounts) {
const startTime = latestTime() + duration.seconds(1); // one second in the future
const endTime = startTime + (86400 * 30); // 30 days
const rate = new web3.BigNumber(1000);
const wallet = accounts[0];
return deployer.deploy(CoinCrowdsale, startTime, endTime, rate, wallet);
}
Die Änderungen await
warten darauf, dass die Versprechungen tatsächlich abgeschlossen werden.
0xgoku