caver-js에서 contract.getPastEvents를 실행하면 항상 Error: Returned error: query timeout exceeded
가 뜨면서 실패합니다.
안녕하세요.
에러 재현이 가능한 간단한 예제 소스코드 첨부 부탁드립니다.
안녕하세요. 예제 코드 올려드립니다.
const address = '0xC820e7b1EC1077Da8667149632A1A41a506cA690';
const abi = [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "owner",
"type": "address"
},
{
"indexed": true,
"name": "spender",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "recipient",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "sender",
"type": "address"
},
{
"name": "recipient",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "spender",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
const contract = new caver.klay.Contract(abi, address);
const pastEvents = await contract.getPastEvents('Mint', {
fromBlock: 0,
toBlock: 'latest',
});
EN은 무엇을 사용하셨나요? 필터링을 할 때 제한이 있습니다.
fromBlock과 toBlock을 사용하셔서 적절한 범위로 끊어서 요청해 보시기 바랍니다.
KAS를 사용하고 있습니다.
fromBlock을 조절하니 되네요.(이벤트 개수가 적으면 0으로 시작해도 됩니다).
해당 정보가 KAS든, Caver쪽이든 공식 문서에 추가되면 좋을 것 같습니다.
감사합니다~