app.get("/contract", async (req, res) => {
const contract = await Newcontract();
console.log(‘결과’);
let result = await contract.methods.Bye(); // [2]
console.log(result);
});
이럴시 결과 값이
{
call: [Function: bound _executeMethod] AsyncFunction {
request: [Function: bound _executeMethod] AsyncFunction
},
sign: [Function: bound _executeMethod] AsyncFunction,
signAsFeePayer: [Function: bound _executeMethod] AsyncFunction,
send: [Function: bound _executeMethod] AsyncFunction {
request: [Function: bound _executeMethod] AsyncFunction
},
encodeABI: [Function: bound _encodeMethodABI],
estimateGas: [Function: bound _executeMethod] AsyncFunction,
arguments: [],
_method: {
constant: true,
inputs: [],
name: ‘Bye’,
outputs: [ [Object] ],
payable: false,
stateMutability: ‘pure’,
type: ‘function’,
signature: ‘0xd1b8a5aa’
},
_parent: Contract {
currentProvider: [Getter/Setter],
_provider: [Getter/Setter],
_requestManager: RequestManager {
provider: [HttpProvider],
providers: [Object],
subscriptions: {}
},
providers: {
WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider]
},
setProvider: [Function (anonymous)],
setRequestManager: [Function (anonymous)],
BatchRequest: [Function: bound Batch],
clearSubscriptions: [Function (anonymous)],
options: {
address: [Getter/Setter],
jsonInterface: [Getter/Setter],
from: [Getter/Setter],
feePayer: [Getter/Setter],
feeDelegation: [Getter/Setter],
feeRatio: [Getter/Setter],
gasPrice: [Getter/Setter],
gas: [Getter/Setter],
data: [Getter/Setter]
},
defaultAccount: [Getter/Setter],
defaultBlock: [Getter/Setter],
methods: {
SayHello: [Function: bound _createTxObject],
‘0x3acb3150’: [Function: bound _createTxObject],
‘SayHello()’: [Function: bound _createTxObject],
constructor: [Function: bound _createTxObject],
Bye: [Function: bound _createTxObject],
‘0xd1b8a5aa’: [Function: bound _createTxObject],
‘Bye()’: [Function: bound _createTxObject]
},
events: { allEvents: [Function: bound ] },
_address: ‘0x06A09448Ce035F05134EFCD61F66a84a2f68066b’,
_jsonInterface: [ [Object], [Object] ]
},
_klayAccounts: <ref *1> Accounts {
currentProvider: [Getter/Setter],
_provider: [Getter/Setter],
_requestManager: RequestManager {
provider: [HttpProvider],
providers: [Object],
subscriptions: {}
},
providers: {
WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider]
},
setProvider: [Function (anonymous)],
setRequestManager: [Function (anonymous)],
_klaytnCall: {
getChainId: [Function],
getGasPrice: [Function],
getTransactionCount: [Function]
},
wallet: Wallet {
_accounts: [Circular *1],
length: 0,
defaultKeyName: ‘caverjs_wallet’
}
},
_wallet: undefined
}
[nodemon] restarting due to changes…
[nodemon] starting node index.js
서버 구동중입니다!
결과
{
call: [Function: bound _executeMethod] AsyncFunction {
request: [Function: bound _executeMethod] AsyncFunction
},
sign: [Function: bound _executeMethod] AsyncFunction,
signAsFeePayer: [Function: bound _executeMethod] AsyncFunction,
send: [Function: bound _executeMethod] AsyncFunction {
request: [Function: bound _executeMethod] AsyncFunction
},
encodeABI: [Function: bound _encodeMethodABI],
estimateGas: [Function: bound _executeMethod] AsyncFunction,
arguments: [],
_method: {
constant: true,
inputs: [],
name: ‘Bye’,
outputs: [ [Object] ],
payable: false,
stateMutability: ‘pure’,
type: ‘function’,
signature: ‘0xd1b8a5aa’
},
_parent: Contract {
currentProvider: [Getter/Setter],
_provider: [Getter/Setter],
_requestManager: RequestManager {
provider: [HttpProvider],
providers: [Object],
subscriptions: {}
},
providers: {
WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider]
},
setProvider: [Function (anonymous)],
setRequestManager: [Function (anonymous)],
BatchRequest: [Function: bound Batch],
clearSubscriptions: [Function (anonymous)],
options: {
address: [Getter/Setter],
jsonInterface: [Getter/Setter],
from: [Getter/Setter],
feePayer: [Getter/Setter],
feeDelegation: [Getter/Setter],
feeRatio: [Getter/Setter],
gasPrice: [Getter/Setter],
gas: [Getter/Setter],
data: [Getter/Setter]
},
defaultAccount: [Getter/Setter],
defaultBlock: [Getter/Setter],
methods: {
SayHello: [Function: bound _createTxObject],
‘0x3acb3150’: [Function: bound _createTxObject],
‘SayHello()’: [Function: bound _createTxObject],
constructor: [Function: bound _createTxObject],
Bye: [Function: bound _createTxObject],
‘0xd1b8a5aa’: [Function: bound _createTxObject],
‘Bye()’: [Function: bound _createTxObject]
},
events: { allEvents: [Function: bound ] },
_address: ‘0x06A09448Ce035F05134EFCD61F66a84a2f68066b’,
_jsonInterface: [ [Object], [Object] ]
},
_klayAccounts: <ref *1> Accounts {
currentProvider: [Getter/Setter],
_provider: [Getter/Setter],
_requestManager: RequestManager {
provider: [HttpProvider],
providers: [Object],
subscriptions: {}
},
providers: {
WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider]
},
setProvider: [Function (anonymous)],
setRequestManager: [Function (anonymous)],
_klaytnCall: {
getChainId: [Function],
getGasPrice: [Function],
getTransactionCount: [Function]
},
wallet: Wallet {
_accounts: [Circular *1],
length: 0,
defaultKeyName: ‘caverjs_wallet’
}
},
_wallet: undefined
}
나오는데
app.get("/contract", async (req, res) => {
const contract = await Newcontract();
console.log(‘결과’);
let result = await contract.methods.Bye().call(); // [2]
console.log(result);
});이렇게 call()함수를 붙여서 함수자체를 사용하려고하면
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 ABI.decodeParametersWith (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-abi/src/index.js:585:19)
at ABI.decodeParameters (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-abi/src/index.js:567:21)
at Contract._decodeMethodReturn (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-contract/src/index.js:924:24)
at Method.outputFormatter (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-contract/src/index.js:1536:42)
at _formatOutput (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-core-method/src/index.js:213:87)
at Method.formatOutput (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-core-method/src/index.js:217:60)
at /Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-core-method/src/index.js:246:25
at /Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-core-requestmanager/src/index.js:162:17
at XMLHttpRequest.request.onreadystatechange (/Users/anhyeongjun/Desktop/coding/codeStates/BlockChain/HA4/KAS/node_modules/caver-js/packages/caver-core-requestmanager/caver-provid
이런 오류가 발생합니다 이유를 알 수 있을까요?