Solidity 尝试访问“目录”时出现块菌控制台错误;总供应量“;我的Dapp中的代币数量

Solidity 尝试访问“目录”时出现块菌控制台错误;总供应量“;我的Dapp中的代币数量,solidity,truffle,Solidity,Truffle,以下是我目前在合同目录中的文件: pragma solidity >=0.4.22 <0.9.0; contract Token { uint256 public totalSupply; constructor(uint _initialSupply) public { totalSupply = _initialSupply; } } const Token = artifacts.require("DovToken&quo

以下是我目前在合同目录中的文件:

pragma solidity >=0.4.22 <0.9.0;

contract Token {
    uint256 public totalSupply;

    constructor(uint _initialSupply) public {
        totalSupply = _initialSupply;
    }
}
const Token = artifacts.require("DovToken");

module.exports = function (deployer) {
    deployer.deploy(Token, 10000);
};

因此,我打开块菌控制台,输入以下内容:

truffle(development)> Token.deployed().then(function(instance) {token = instance;})
到目前为止还不错。现在,这里是我得到错误的地方:

块菌(开发)>token.totalSupply()

然后我得到这个:

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)'
}
错误:返回的值无效,是否汽油用完了?如果您没有为要从中检索数据的协定使用正确的ABI、从不存在的块号请求数据或查询未完全同步的节点,则也可能会看到此错误。
在评估机器上:0:3
在sigintHandlersWrap(vm.js:272:15)
位于Script.runInContext(vm.js:127:14)
运行脚本时(/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:270:1)
在Console.explait(/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/Console.js:285:1)
绑定时(domain.js:427:14)
在REPLServer.runBound[as eval](domain.js:440:12)
在REPLServer.onLine上(repl.js:760:10)
在REPLServer.emit上(events.js:315:20)
位于REPLServer.EventEmitter.emit(domain.js:483:12)
在REPLServer.Interface.\u在线(readline.js:329:10)
在REPLServer.Interface._行(readline.js:658:8)
在REPLServer.Interface.\u ttyWrite(readline.js:1003:14)
在REPLServer.self.\u ttyWrite(repl.js:850:9)
在ReadStream.onkeypress(readline.js:205:10)
在ReadStream.emit(events.js:315:20)
位于ReadStream.EventEmitter.emit(domain.js:483:12)
at-emitKeys(internal/readline/utils.js:335:14)
在emitKeys.next()处
在ReadStream.onData(readline.js:1137:36){
hijackedStack:“错误:返回的值无效,是否耗尽了气体?如果您没有为要从中检索数据的合同使用正确的ABI,从不存在的块号请求数据,或查询未完全同步的节点,您也可能会看到此错误。\n”+
'在ABICoder.decodeParametersWith(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u modules/web3 eth abi/lib/index.js:298:1)\n'+
'在ABICoder.decodepartameters(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u modules/web3 eth abi/lib/index.js:285:1)\n'+
'at Contract.\u decode方法返回(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u modules/web3 eth/node\u modules/web3 eth Contract/lib/index.js:470:1)\n'+
'在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'+
'在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'+
'在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'+
'在XMLHttpRequestEventTarget.dispatchEvent(/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2 cookies/dist/xml http请求事件target.js:34:1)\n'+
'在XMLHttpRequest.exports.modules.996763.XMLHttpRequest.\u setReadyState(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u modules/xhr2 cookies/dist/xml http request.js:208:1)\n'+
'在XMLHttpRequest.exports.modules.996763.XMLHttpRequest.\u onhttpresponseed(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u modules/xhr2 cookies/dist/xml http request.js:318:1)\n'+
'at IncomingMessage.(/usr/local/lib/node\u modules/truffle/build/webpack:/node\u 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'+
'在endReadableNT(\u stream\u readable.js:1220:12)\n'+
'at processTicksAndRejections(internal/process/task_queues.js:84:21)'
}
现在我很困惑。它应该返回一些引用令牌数量(10000)的信息