2_deploy_contracts.js
=====================
Replacing 'SimpleStorage'
-------------------------
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({
code: -32603,
message: 'ETIMEDOUT',
data: { originalError: { code: 'ETIMEDOUT', connect: true } },
stack: 'Error: ETIMEDOUT\n' +
' at Timeout.<anonymous> (D:\\Downloads\\eattheblocks-master\\screencast\\321-connect-frontend-contract-bsc\\node_modules\\request\\request.js:848:19)\n' +
' at listOnTimeout (internal/timers.js:557:17)\n' +
' at processTimers (internal/timers.js:500:7)'
})
at Web3ProviderEngine.emit (events.js:364:17)
at D:\Downloads\eattheblocks-master\screencast\321-connect-frontend-contract-bsc\node_modules\#trufflesuite\web3-provider-engine\index.js:57:14
Truffle v5.4.3 (core: 5.4.3)
Solidity - 0.8.0 (solc-js)
Node v14.17.3
Web3.js v1.5.0
Make sure ganache is running if you are using that. Also provide your truffle config file and migration file for more information.
Related
here is my 2_deploy_contract.js syntax
const DerbyToken = artifacts.require("./DerbyToken.sol");
module.exports = function(deployer) {
// Deploy the Migrations contract as our only task
deployer.deploy(DerbyToken);
};
after I migrate the file using truffle I receive this error message
Error: Migration /home/cyraidz/token_sale/migrations/2_deploy_contracts.js invalid or does not take any parameters
at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.3.5 (core: 5.3.5)
Node v10.19.0
Add a newline at the end of "2_deploy_contract.js"
I have a contract like following -
File Name: dummycontrat.sol
pragma solidity ^0.4.17;
contract DummyContract {
function fetchRandomNumber() public pure returns(uint) {
uint res = 10;
return res;
}
}
I have the following test file -
FileName: test/TestDummyContract.sol
pragma solidity ^0.4.17;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/dummycontract.sol";
contract TestDummyContract {
function testRandomNumberNew() public {
DummyContract dummyContract = new DummyContract();
uint randomNumber = dummyContract.fetchRandomNumber();
Assert.equal(randomNumber, 10, "Number is not 10");
}
function testRandomNumberDeployed() public {
DummyContract dummyContract = DummyContract(DeployedAddresses.DummyContract());
uint randomNumber = dummyContract.fetchRandomNumber();
Assert.equal(randomNumber, 10, "Number is not 10");
}
}
I run the command -
truffle compile && truffle migrate --reset --network dev && truffle test --network dev test/TestDummyContract.sol
The first test passes while the second gives an error. Logs from the truffle test command is following -
TestDummyContract
✓ testRandomNumberNew (53ms)
1) testRandomNumberDeployed
> No events were emitted
1 passing (894ms)
1 failing
1) TestDummyContract testRandomNumberDeployed:
Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
Can anyone explain what's the problem here? I am running Ganache tool on OSX for the network.
DeployedAddresses.DummyContract() is failing because only contracts that are included in the Truffle deployment configurations are made available to DeployedAddresses. From the Truffle documentation:
The addresses of your deployed contracts (i.e., contracts that were deployed as part of your migrations) are available through the truffle/DeployedAddresses.sol library. This is provided by Truffle and is recompiled and relinked before each suite is run to provide your tests with Truffle's a clean room environment. This library provides functions for all of your deployed contracts, in the form of:
DeployedAddresses.<contract name>();
To fix your issue, you need to create the deployment configuration under /migrations (or add to your existing one, if you have it). For example:
2_deploy_contracts.js:
var DummyContract = artifacts.require("dummycontract");
module.exports = function(deployer) {
deployer.deploy(DummyContract);
};
Add that configuration, rerun truffle migrate --reset then your test will work.
im trying to run gulp in node console and I get an error like below. I was looking over the net for a solution, but nothing has work so far. Hope you can help me.
C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:298
throw new Error('Invalid mapping: ' + JSON.stringify({
^
Error: Invalid mapping: {"generated":{"line":157,"column":3},"source":"../bower_components/bootstrap/scss/mixins/_hover.scss","original":{"line":12,"column":-19},"name":null}
at SourceMapGenerator_validateMapping [as _validateMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:298:13)
at SourceMapGenerator_addMapping [as addMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-generator.js:110:12)
at C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\concat-with-sourcemaps\index.js:60:28
at Array.forEach ()
at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\source-map\lib\source-map-consumer.js:157:14)
at Concat.add (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\concat-with-sourcemaps\index.js:58:18)
at DestroyableTransform.bufferContents [as _transform] (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\gulp-concat\index.js:68:12)
at DestroyableTransform.Transform._read (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_transform.js:182:10)
at DestroyableTransform.Transform._write (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_transform.js:170:83)
at doWrite (C:\xampp\htdocs\wicie\wp-content\themes\domki-wicie\node_modules\readable-stream\lib\_stream_writable.js:406:64)
Node version - 8.9.4
npm version - 5.6.0
source-map version - 0.6.1
I am using truffle#2.1.2 to deploy smart contracts against a localhost:8545 geth#1.5.9-stable rpc, using an account that is funded with Ether has been unlocked using personal.unlockAccount on the geth console.
I have also tried the same against a remote Parity node via RPC, but this is the latest which I am rather stuck with.
truffle.js
module.exports = {
build: {
"index.html": "index.html",
"app.js": [
"javascripts/app.js"
],
"app.css": [
"stylesheets/app.css"
],
"images/": "images/"
},
rpc: {
host: "localhost",
port: 8545
},
networks: {
"ropsten": {
network_id: 3,
port: 8548, // ssh tunnelled to AWS geth/parity node localhost:8545
from: "0x4f000Bcf4641E2fDcE85BF26A694b053996850D4"
},
"live": {
network_id: 1,
port: 8545,
from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
gas: 4612388,
gasPrice: 2776297000 // taken from Parity startup log message "Updated conversion rate to Ξ1 = US$42.88 (2776297000 wei/gas)"
}
}
};
truffle migrate --network live
Running migration: 1_initial_migration.js
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Exceeds block gas limit
at Object.module.exports.InvalidResponse (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
at /home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
at request.onreadystatechange (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
at dispatchEvent (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
at setState (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
at IncomingMessage.<anonymous> (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:926:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)
I have tried adjusting gas and gasPrice, but am unable to find values that have any affect.
How can I solve this problem, or are there alternative contract deployment methods I should look into?
Kind Regards.
I was able to solve this by simply setting gas: 3000000 in the network config.
"live": {
network_id: 1,
port: 8545,
from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
gas: 3000000
}
It cost about 0.5 ETH to run migrations and took several minutes.
In my case the problem was generated by a user's empty balance.
so check your balances using the following function :
function checkAllBalances() {
var totalBal = 0;
for (var acctNum in eth.accounts) {
var acct = eth.accounts[acctNum];
var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
totalBal += parseFloat(acctBal);
console.log(" eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
}
console.log(" Total balance: " + totalBal + " ether");
};
checkAllBalances();
if the balance is 0 mine some blocks or edit your genesis file.
I solve the same problem by indicate the network id when calling truffle,as:
truffle migrate --network live
and you should modify "from" tag in truffle.js with your unlocked account.
Simple solution: : add gas: 500000 ,(don`t forget to add comma at the last) in truffle.js
module.exports = {
networks: {
development: {
host: "localhost",
port: 8001,
network_id: 1234, // Match any network id
gas: 500000
}
}
};
While trying out the ethereum contract mentioned at the tutorial: https://medium.com/#ConsenSys/a-101-noob-intro-to-programming-smart-contracts-on-ethereum-695d15c1dab4#.ilmaiavg0 (source code for the tutorial: https://github.com/eshon/conference), I get the following error while doing truffle migrate:
test#test-ubuntu:~/Blockchain/Ethereum/conference$ truffle migrate
Running migration: 1_initial_migration.js
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Server error
at Object.module.exports.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
at [object Object].request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
at [object Object].dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
at setState (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:905:12)
at nextTickCallbackWith2Args (node.js:441:9)
at process._tickDomainCallback (node.js:396:17)
testrpc is up and running, and I see following two lines in testrpc terminal when I run truffle migrate:
127.0.0.1 - - [2016-10-21 09:38:17] "POST / HTTP/1.1" 200 718 0.001741
127.0.0.1 - - [2016-10-21 09:38:17] "POST / HTTP/1.1" 200 493 0.042596
Am I missing anything in the configuration?
My Source Code is at https://github.com/manindra23/conference-contract/tree/develop
Can you just try to give network setup in truffle.js file
like this,
networks: {
development: {
host: 'localhost',
port: 8545,
network_id: '*' // Match any network id
}
}