Solidity - Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct - solidity

I can run the set function with values with instance.SetUserInfo('Neil', 43) and I get a confirmation that it's a success, when I try to get function with instance.GetUserInfo('Neil')
My command line commands are as follows:
let instance = await test.deployed()
instance.SetUserInfo('Neil', 43)
instance.GetUserInfo('Neil')
I receive the following error:
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at evalmachine.<anonymous>:1:18
at evalmachine.<anonymous>:2:49
at sigintHandlersWrap (vm.js:273:12)
at Script.runInContext (vm.js:140:14)
at runScript (C:\Users\mcbai\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:366:1)
at Console.interpret (C:\Users\mcbai\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:381:1)
at bound (domain.js:416:15)
at REPLServer.runBound [as eval] (domain.js:427:12)
at REPLServer.onLine (repl.js:819:10)
at REPLServer.emit (events.js:376:20)
at REPLServer.emit (domain.js:470:12)
at REPLServer.Interface._onLine (readline.js:342:10)
at REPLServer.Interface._line (readline.js:671:8)
at REPLServer.Interface._ttyWrite (readline.js:1015:14) {
hijackedStack: "Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.\n" +
' at ABICoder.decodeParametersWith (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth-abi\\lib\\index.js:297:1)\n' +
' at ABICoder.decodeParameters (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth-abi\\lib\\index.js:284:1)\n' +
' at Contract._decodeMethodReturn (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth\\node_modules\\web3-eth-contract\\lib\\index.js:469:1)\n' +
' at Method.outputFormatter (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth\\node_modules\\web3-eth-contract\\lib\\index.js:759:1)\n' +
' at Method.formatOutput (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth\\node_modules\\web3-core-method\\lib\\index.js:146:1)\n' +
' at sendTxCallback (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3-eth\\node_modules\\web3-core-method\\lib\\index.js:522:1)\n' +
' at C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3\\node_modules\\web3-core-requestmanager\\lib\\index.js:307:1\n' +
' at C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\packages\\provider\\wrapper.js:119:1\n' +
' at XMLHttpRequest.request.onreadystatechange (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\web3\\node_modules\\web3-providers-http\\lib\\index.js:98:1)\n' +
' at XMLHttpRequestEventTarget.dispatchEvent (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\xhr2-cookies\\dist\\xml-http-request-event-target.js:34:1)\n' +
' at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._setReadyState (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:208:1)\n' +
' at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._onHttpResponseEnd (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:318:1)\n' +
' at IncomingMessage.<anonymous> (C:\\Users\\mcbai\\AppData\\Roaming\\npm\\node_modules\\truffle\\build\\webpack:\\node_modules\\xhr2-cookies\\dist\\xml-http-request.js:289:48)\n' +
' at IncomingMessage.emit (events.js:388:22)\n' +
' at IncomingMessage.emit (domain.js:532:15)\n' +
' at endReadableNT (internal/streams/readable.js:1336:12)'
}
My .sol file:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
contract test {
struct UserInfo {
uint Age;
bool AgeRestriction;
}
mapping (string => UserInfo) AllUsers;
function SetUserInfo(string memory _Name, uint _Age) public {
AllUsers[_Name].Age = _Age;
if (AllUsers[_Name].Age >= 18) {AllUsers[_Name].AgeRestriction = false;
}
else AllUsers[_Name].AgeRestriction = true;
}
function GetUserInfo(string memory _Name) public view returns (uint) {
return (AllUsers[_Name].Age);
}
}

Well I will be damned, for whatever reason this worked.
instead of using:
truffle develop
I used
truffle console
and it worked
Hope someone finds this useful

Related

Truffle Console Error When Trying To Access The "totalSupply" Of Tokens In My Dapp

Here's the file I have so far in my contracts directory:
pragma solidity >=0.4.22 <0.9.0;
contract Token {
uint256 public totalSupply;
constructor(uint _initialSupply) public {
totalSupply = _initialSupply;
}
}
And the text in the file I have in my migrations directory:
const Token = artifacts.require("DovToken");
module.exports = function (deployer) {
deployer.deploy(Token, 10000);
};
So I open the truffle console, and enter this:
truffle(development)> Token.deployed().then(function(instance) {token = instance;})
So far so good. Now, here's where I get the error:
truffle(development)> token.totalSupply()
Then I get this:
Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
at evalmachine.<anonymous>:0:3
at sigintHandlersWrap (vm.js:272:15)
at Script.runInContext (vm.js:127:14)
at runScript (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:270:1)
at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:285:1)
at bound (domain.js:427:14)
at REPLServer.runBound [as eval] (domain.js:440:12)
at REPLServer.onLine (repl.js:760:10)
at REPLServer.emit (events.js:315:20)
at REPLServer.EventEmitter.emit (domain.js:483:12)
at REPLServer.Interface._onLine (readline.js:329:10)
at REPLServer.Interface._line (readline.js:658:8)
at REPLServer.Interface._ttyWrite (readline.js:1003:14)
at REPLServer.self._ttyWrite (repl.js:850:9)
at ReadStream.onkeypress (readline.js:205:10)
at ReadStream.emit (events.js:315:20)
at ReadStream.EventEmitter.emit (domain.js:483:12)
at emitKeys (internal/readline/utils.js:335:14)
at emitKeys.next (<anonymous>)
at ReadStream.onData (readline.js:1137:36) {
hijackedStack: "Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.\n" +
' at ABICoder.decodeParametersWith (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/lib/index.js:298:1)\n' +
' at ABICoder.decodeParameters (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth-abi/lib/index.js:285:1)\n' +
' at Contract._decodeMethodReturn (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:470:1)\n' +
' at Method.outputFormatter (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-eth-contract/lib/index.js:760:1)\n' +
' at Method.formatOutput (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/lib/index.js:147:1)\n' +
' at sendTxCallback (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-eth/node_modules/web3-core-method/lib/index.js:523:1)\n' +
' at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-core-requestmanager/lib/index.js:308:1\n' +
' at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:107:1\n' +
' at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/lib/index.js:98:1)\n' +
' at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)\n' +
' at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)\n' +
' at XMLHttpRequest.exports.modules.996763.XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)\n' +
' at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)\n' +
' at IncomingMessage.emit (events.js:327:22)\n' +
' at IncomingMessage.EventEmitter.emit (domain.js:506:15)\n' +
' at endReadableNT (_stream_readable.js:1220:12)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:84:21)'
}
And now I'm confused. It's supposed to return some information referencing the amount of tokens (10000).

Incoming Express parameters are not the same as whats passed in

I have a strange issue where I have passed in parameters from a URL, into my Express server,
When I get the req.params.code & req.params.mode variables, they are different than what is passed in through the URL.
Allow me to show you...
Here is the Express code:
router.get('/verify/:user/:mode/:code', function(req,res){
console.log("STARTING VERIFICATION");
var code = req.params.code;
console.log('code: ' + code);
var user = req.params.user;
console.log('user: ' + user);
var mode = req.params.mode;
console.log('mode: ' + mode);
console.log('req.params: ' + JSON.stringify(req.params));
var regex = new RegExp(["^", req.params.user, "$"].join(""), "i");
console.log('REGEX: ' + regex);
var verified = false;
console.log('req.params: ' + req.params);
console.log('req.body: ' + req.body);
console.log("rx: "+ regex);
console.log('req.params.code: ' + req.params.code);
console.log('req.params.user: ' + req.params.user);
etc... etc... etc...
Here is the output in the console:
STARTING VERIFICATION
code: background-cycler.js
user: admin
mode: js
req.params: {"user":"admin","mode":"js","code":"background-cycler.js"}
REGEX: /^admin$/i
req.params: [object Object]
req.body: [object Object]
rx: /^admin$/i
req.params.code: background-cycler.js
req.params.user: admin
Here is the URL that is passed into the browser:
https://examplesite.com/verify/admin/sms/9484
I want to say that this code worked prior to dusting it off and moving an instance to google's cloud compute...
As you can see, the parameters passed in to the verify, code should be 9484 and mode should be sms. Instead i'm getting an unintended js filename, and a js mode instead.
UPDATE: As requested I added this within the Express route function:
console.log(req.originalUrl);
and I get this result:
/verify/admin/js/background-cycler.js
I can verify the URL that sent this was:
https://examplesite.com/verify/admin/sms/9484

SDK_ERROR At least one participant (other than self is required)

Hi Once I fill the contact form in and press the submit button i'm getting the following error, can anyone provide any assistance?
Error creating new complaint Error
at new circuit.Error (C:\Users\chrisconnolly\customer-support\node_modules\circuit-sdk\circuit.js:311:22)
at C:\Users\chrisconnolly\customer-support\node_modules\circuit-sdk\circuit.js:55977:28
at new Promise (<anonymous>)
at Object.createGroupConversation (C:\Users\chrisconnolly\customer-support\node_modules\circuit-sdk\circuit.js:55966:20)
at Object.createConversation (C:\Users\chrisconnolly\customer-support\circuit.js:23:19)
at Socket.<anonymous> (C:\Users\chrisconnolly\customer-support\server.js:78:32)
at Socket.emit (events.js:200:13)
at C:\Users\chrisconnolly\customer-support\node_modules\socket.io\lib\socket.js:513:12
at processTicksAndRejections (internal/process/task_queues.js:82:9) {
code: 'SDK_ERROR',
message: 'At least one participant (other than self) is required',
stack: 'Error\n at new circuit.Error ' +
'(C:\\Users\\chrisconnolly\\customer-support\\node_modules\\circuit-sdk\\circuit.js:311:22)\n' +
' at ' +
'C:\\Users\\chrisconnolly\\customer-support\\node_modules\\circuit-sdk\\circuit.js:55977:28\n' +
' at new Promise (<anonymous>)\n at ' +
'Object.createGroupConversation ' +
'(C:\\Users\\chrisconnolly\\customer-support\\node_modules\\circuit-sdk\\circuit.js:55966:20)\n' +
' at Object.createConversation ' +
'(C:\\Users\\chrisconnolly\\customer-support\\circuit.js:23:19)\n at ' +
'Socket.<anonymous> ' +
'(C:\\Users\\chrisconnolly\\customer-support\\server.js:78:32)\n at ' +
'Socket.emit (events.js:200:13)\n at ' +
'C:\\Users\\chrisconnolly\\customer-support\\node_modules\\socket.io\\lib\\socket.js:513:12\n' +
' at processTicksAndRejections ' +
'(internal/process/task_queues.js:82:9)'
Questions on specific example apps are better post in their respective repo's issues page. I.e. https://github.com/circuit/customer-support/issues
Now looking at the error you get, it says "server.js:78" (https://github.com/circuit/customer-support/blob/master/server.js#L78) which is the createConversation API. And given the error says "At least one participant (other than self) is required", I suspect you are not passing any users as first parameter. Looking at https://github.com/circuit/customer-support/blob/master/server.js#L54 shows that those supportUsers come from the config file "config.json".
Did you rename config.json.template to config.json as per instructions in the README? And did you edit the config file (https://github.com/circuit/customer-support/blob/master/config.json.template#L26) with those support users?

Calling Google Spreadsheets and Vue

Good morning,
I am using this library (https://github.com/theoephraim/node-google-spreadsheet) to work with Google Sheets, and it seems like the authentication is working properly, but when I am recovering the sheets to work with them, it is throwing me a weird error and I don't know how to fix it.
It's not working the following code (in doc.getInfo):
function getInfoAndWorksheets (step) {
console.log('jj')
doc.getInfo(function (err, info) {
console.log('cvcv')
console.log(info)
console.log('Loaded doc: ' + info.title + ' by ' + info.author.email)
var sheet = info.worksheets[0]
console.log('sheet 1: ' + sheet.title + ' ' + sheet.rowCount + 'x' + sheet.colCount)
console.log(err)
step()
})
}
The error is the next one: err = Error: incorrect header check at Zlib._handle.onerror (webpack-internal:///./node_modules/browserify-zlib/lib/index.js:352:17) at Zlib._error (
You can see the error in the next photo:
https://www.photobox.co.uk/my/photo/full?photo_id=501798366536
Try this
const doc = new GoogleSpreadsheet('<Spreadsheet ID>', null, { gzip: false })

AppWarp onPrivateUpdateReceived doesn't work

var codestring = this.ball + " " + this.ball.position["x"] + " "
+ this.ball.position["y"];
_warpclient.sendPrivateUpdatePeers(enemy, codestring);
I use this function to send peers to the person with defined name enemy.
function onSendPrivateUpdateDone (result){
console.log('Update done ' + result);
}
onSendPrivateUpdateDone works and write messages to person who send peers, here https://apphq.shephertz.com/appWarp/index#/testManager it's noted that my messages are sent, room is created and players are connected to the room, but the person who must accept message doesn't do that, because function onPrivateUpdateReceived callback does nothing.
onPrivateUpdateReceived(userName, msg){
console.log("Username: "+userName);
console.log("Message: "+msg);
}
onPrivateUpdateReceived recieves msgs from the tosendPrivateUpdate method, you should change sendPrivateUpdatePeers to sendPrivateUpdate to work.