Truffle error: Error: VM Exception while processing transaction: revert - blockchain

I am using truffle:
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
i am getting below error in Truffle
***Error: VM Exception while processing transaction: revert
at Object.InvalidResponse (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:41484:16)
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:328866:36
at C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:324536:9
at XMLHttpRequest.request.onreadystatechange (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:327565:7)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176407:18)
at XMLHttpRequest._setReadyState (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176697:12)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176852:12)
at IncomingMessage.<anonymous> (C:\Users\dell\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:176812:24)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7) ***
1) My HelloWorld.sol
`
pragma solidity ^0.4.8;
contract HelloWorld {
function SayHello() public returns (string) {
return ("SomeHello");
}
}
2) My 2_deploy_contracts.js
var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
var HelloWorld = artifacts.require("./HelloWorld.sol");
var second = artifacts.require("./second.sol");
module.exports = function(deployer) {
deployer.deploy(ConvertLib);
deployer.link(ConvertLib, MetaCoin);
deployer.deploy(MetaCoin);
deployer.deploy(HelloWorld);
deployer.deploy(second);
};
3) My truffle.js
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Please let me know how can I fix above error ?
`

I just ran your example and it worked fine. The only change I made was I removed the other smart contracts from 2_deploy_contracts that aren't used. Make sure you are running the compile and migrate commands and testrpc is running before starting the truffle console. Also, just in case you're running on Windows, rename truffle.js to truffle-config.js
$ truffle compile
Compiling .\contracts\HelloWorld.sol...
Writing artifacts to .\build\contracts
$ truffle migrate
Using network 'development'.
Running migration: 2_deploy_contracts.js
Deploying HelloWorld...
... 0xef7e895758805a3c3c9aaed7dc7c97fe7b2278b0c0d6ee8105192183a86188c9
HelloWorld: 0x54329ff919efda7920408084590d7480a6c88243
Saving successful migration to network...
... 0x0954625bf66275469c9475ca21f5db20bc4667efb716c5e19bfd98a9553f4a83
Saving artifacts...
$ truffle console
truffle(development)> var hw
undefined
truffle(development)> HelloWorld.deployed().then(function(deployed){hw=deployed;});
undefined
truffle(development)> hw.SayHello.call()
'SomeHello'
truffle(development)>
2_deploy_contracts.js
var HelloWorld = artifacts.require("./HelloWorld.sol");
module.exports = function(deployer) { deployer.deploy(HelloWorld); };

Related

detox[3338] DEBUG: [APP_STATUS] Failed to execute the current status query

I try to add detox to my expo application, everthing seams to work fine, but when I try to run the test I get following error message.
detox[3338] DEBUG: [APP_STATUS] Failed to execute the current status query.
firstTest.e2e.ts
const { reloadApp } = require('detox-expo-helpers');
describe('Example', () => {
beforeAll(async () => {
await reloadApp({
permissions: {
location: 'always',
userTracking: 'YES'
}
})
});
it('test', async () => {
await expect(element(by.id('settings'))).toBeVisible()
await element(by.id('settings')).tap()
console.log('success')
})
})
At first I start the expo server with yarn expo start --ios and then run the detox test with yarn detox test -c ios --loglevel trace. The app will be installed and loaded but stucks at the error message. Did any one has an solution?

Mongoose DocumentDB connection fails through SSH tunnel

I am trying to connect to AWS DocumentDB with Node.js/Typescript and Mongoose. I have an EC2 instance setup as SSL tunnel, which works great. I can connect to DocumentDB locally with Studio3T and mongo-cli.
This command works mongo --sslAllowInvalidHostnames --ssl --sslCAFile rds-combined-ca-bundle.pem --username <username> --password <password>
But if I try to connect to the same database with Mongoose, it fails. This is my code and the error:
const options = {
dbName: "prodDB",
user: connectionData.username,
pass: connectionData.password,
tls: true,
tlsCAFile: "../rds-combined-ca-bundle.pem",
tlsAllowInvalidHostNames: true,
};
try {
await connect("mongodb://localhost:27017", options);
} catch (error) {
console.log(error);
}
MongooseServerSelectionError: connect EHOSTUNREACH imagine-ip-address-here:27017
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
'censored:27017' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'rs0',
commonWireVersion: 7,
logicalSessionTimeoutMinutes: undefined
}
At this point, I have tried pretty much any possible config in Mongoose and I am getting desperate. Any help is appreciated
This seems to be an issue with mongoose versions >= 6.
Downgrading Mongoose to version 5.13.8 works without a problem.
Mongoose devs are apparently aware of this issue: https://github.com/Automattic/mongoose/issues/11105

Error: Deployment Failed while using Matic Test Network

I am getting started with Application development on Matic. And I am following the instruction as provided on the docs https://docs.matic.network/docs/develop/getting-started
But I faced problem while using truffle. After I run the command
truffle migrate --network matic
The error as follow:
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Starting migrations...
======================
> Network name: 'matic'
> Network id: 80001
> Block gas limit: 20000000 (0x1312d00)
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
Error: *** Deployment Failed ***
"Migrations" -- insufficient funds for gas * price + value.
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.55 (core: 5.1.55)
Node v10.19.0
The configuration file of truffle as follow:
const HDWalletProvider = require('truffle-hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
matic: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.matic.today`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
}
}
}
It worked fine for the develop network using
truffle develop
Can someone tell me how to overcome error while using Matic Test Network?
Make sure you have enough MATIC for the transaction, you can get some from here and transfer them to the account[0]. I had issues deploying with truffle as all my tokens were at account[1] rather than account[0]
in my case it was ETH, ensuring i had tokens in the first account did the trick

Problems about 53 bits deploying contracts with Truffle

I am trying to deploy a Smart Contract with truffle 5.1.19 as follows:
pragma solidity 0.5.16;
contract Simple {
string public message;
function Hello(string memory _initialMessage) public {
message = _initialMessage;
}
function setMessage(string memory _newMessage) public {
message = _newMessage;
}
}
When I run a truffle deploy --network mired I have the next error:
Error: Number can only safely store up to 53 bits
at assert (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/bn.js/lib/bn.js:6:1)
at BN.toNumber (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/bn.js/lib/bn.js:506:1)
at Object.hexToNumber (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-utils/src/utils.js:234:1)
at Method.outputBlockFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-helpers/src/formatters.js:236:1)
at Method.web3.eth.getBlock.method.outputFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/packages/interface-adapter/dist/shim/overloads/ethereum.js:37:1)
at Method.formatOutput (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-method/src/index.js:163:1)
at sendTxCallback (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-method/src/index.js:473:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-core-requestmanager/src/index.js:147:1
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:112:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-providers-http/src/index.js:96:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Truffle v5.1.19 (core: 5.1.19)
Node v10.19.0
My truffle-config for my network is the next one:
mired: {
host: "10.xxx.xxx.xxx",
port: 8080, // Custom port
network_id: "*", // Custom network
gas: 0, // Gas sent with each transaction (default: ~6700000)
gasPrice: 0x0, // 20 gwei (in wei) (default: 100 gwei)
from: "0x8...............", // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
},
Doing a downgrade of my truffle to the 4.1.15 version this error dissapears but I don't understand why with an actual version, this error appears. Thanks in advance
If you are working with quorum like it is my case. On truffle-config.js, you have to write type:"quorum" and it solves the problem.

newman execution throwing TypeError: newman.run is not a function

I have newman 3.9.3 version installed on my ubuntu box. Want to execute multiple collections from a folder but executing js file through me wired error saying
TypeError: newman.run is not a function.
Here is my execution script. Any help will be appreciated.
#!/usr/bin/env node
var newman = require(process.env.NVM_BIN+'/newman');
var fs = require('fs');
fs.readdir('./collections', function (err, files) {
if (err) { throw err; }
files = files.filter(function (file) {
return (file.substr(-5) === '.json');
});
// now wer iterate on each file name and call newman.run using each file name
files.forEach(function (file) {
newman.run({
environment: require(`${__dirname}/live.postmane_environment.json`),
collection: require(`${__dirname}/collections/${file}`),
reporters: ['cli']
}, function (err) {
console.info(`${file}: ${err ? err.name : 'ok'}!`);
});
});
});
Following is the exact error.
/app/postman/execute:15
newman.run({
^
TypeError: newman.run is not a function
at /app/postman/execute:15:16
at Array.forEach (native)
at /app/postman/execute:14:11
at FSReqWrap.oncomplete (fs.js:123:15)
For the time being, I've solved this problem by using bash script to run all of my collections available in a folder. that has done the job. but originally i could not understand why "run" is not available for "newman" object.
I was getting the same error message and solved installing the nodejs package:
npm install --save newman
Basically, when you make the bin as reference the nodejs doesnt know how to run:
Instead of:
var newman = require(process.env.NVM_BIN+'/newman');
Should be:
var newman = require('newman');