Reputation: 61
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);
}
}
Upvotes: 1
Views: 136
Reputation: 61
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
Upvotes: 1