bsc
bsc copied to clipboard
missing trie node
System information
use testnet rpc :https://data-seed-prebsc-1-s1.binance.org:8545/
issue
contract call revert , can't find block 20781539
contract.defaultBlock = 20781539
contract.methods
.optionID()
.call()
.catch((err) => {
console.log(err)
})
will show error:
Error: Returned error: missing trie node 7c1d371019866bdc3b8da18c6a235e7c63c92446c5e9ef9f3c7908bd0b778cfd (path )
at Object.ErrorResponse (errors.js:28:19)
at index.js:300:36
at request.onreadystatechange (index.js:98:13)
try these rpcs:
https://data-seed-prebsc-1-s2.binance.org:8545
https://data-seed-prebsc-2-s3.binance.org:8545
I've tried it before, it doesn't work
try with rm -rf /data
i can give u full demo :
const provider = new Web3HttpProvider(
'https://data-seed-prebsc-1-s1.binance.org:8545/'
)
const w = new Web3(provider)
const jsonData = [
{
inputs: [],
stateMutability: 'nonpayable',
type: 'constructor',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'uint256',
name: 'optionID',
type: 'uint256',
},
{
indexed: false,
internalType: 'address',
name: 'account',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'amount',
type: 'uint256',
},
],
name: 'EnteredOption',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'uint256',
name: 'optionID',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'timestamp',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'tokenAmount',
type: 'uint256',
},
],
name: 'Exercised',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'previousOwner',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'newOwner',
type: 'address',
},
],
name: 'OwnershipTransferred',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'uint256',
name: 'optionID',
type: 'uint256',
},
{
indexed: false,
internalType: 'address',
name: 'account',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'baseTokenAmount',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'targetTokenAmount',
type: 'uint256',
},
],
name: 'RedeemedToken',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'uint256',
name: 'optionID',
type: 'uint256',
},
{
indexed: false,
internalType: 'address',
name: 'account',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'targetTokenAmount',
type: 'uint256',
},
],
name: 'WithdrawedTarget',
type: 'event',
},
{
inputs: [],
name: 'bullet',
outputs: [
{
internalType: 'contract IBullet',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_amount',
type: 'uint256',
},
],
name: 'enter',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_targetAmount',
type: 'uint256',
},
],
name: 'exercise',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'exerciseTimestamp',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_amount',
type: 'uint256',
},
],
name: 'exit',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'exitAll',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'fund',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_strikePrice',
type: 'uint256',
},
{
internalType: 'uint256',
name: '_exerciseTimestamp',
type: 'uint256',
},
{
internalType: 'uint8',
name: '_type',
type: 'uint8',
},
],
name: 'initialize',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'optionFactory',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'optionID',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'optionType',
outputs: [
{
internalType: 'uint8',
name: '',
type: 'uint8',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'owner',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'renounceOwnership',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_optionID',
type: 'uint256',
},
{
internalType: 'uint256',
name: '_startBlock',
type: 'uint256',
},
{
internalType: 'address',
name: '_uHODLAddress',
type: 'address',
},
{
internalType: 'address',
name: '_bHODLTokenAddress',
type: 'address',
},
{
internalType: 'address',
name: '_fund',
type: 'address',
},
{
internalType: 'address',
name: '_bullet',
type: 'address',
},
{
internalType: 'address',
name: '_sniper',
type: 'address',
},
],
name: 'setup',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [],
name: 'sniper',
outputs: [
{
internalType: 'contract ISniper',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'stakingPool',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'startBlock',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'strikePrice',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'address',
name: 'newOwner',
type: 'address',
},
],
name: 'transferOwnership',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '_amount',
type: 'uint256',
},
],
name: 'withdrawTarget',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
]
const c = new w.eth.Contract(
jsonData,
'0x76db8a0855ad83a0be682daa23aa108f98e5d282'
)
c.defaultBlock = 20781539 // Contract createed at block 20781539
c.methods.optionID().call().then(res=>console.log(res))