如何读取未发出的以太坊合同存储值?
我想阅读'0x9ec5557208CB28A7714A2EA3468BD9D5BB15125'
的合同存储空间。 我尝试过 -
const Web3 = require('web3')
const rpcURL = "https://bsc-dataseed1.binance.org/"
const web3 = new Web3(rpcURL)
let contractAddress = '0x9EC55d57208cb28a7714A2eA3468bD9d5bB15125'
for (index = 0; index < 10; index++){
console.log(`[${index}]` +
web3.eth.getStorageAt(contractAddress, index,16368474).then(res=>{
console.log(res)
})
)
}
这陷入错误错误:返回错误:找不到标头
。我尝试更改块,但陷入相同的错误。仅当我不通过16368474
时,该错误才能解决,但这使用了最新的
block,这不是我想要的。我尝试使用web3.py
尝试过。它遇到相同的错误。我在做什么错?是否有其他获取存储的方法?
I want to read the contract storage for '0x9EC55d57208cb28a7714A2eA3468bD9d5bB15125'
at block 16368474
on BSC .
I tried -
const Web3 = require('web3')
const rpcURL = "https://bsc-dataseed1.binance.org/"
const web3 = new Web3(rpcURL)
let contractAddress = '0x9EC55d57208cb28a7714A2eA3468bD9d5bB15125'
for (index = 0; index < 10; index++){
console.log(`[${index}]` +
web3.eth.getStorageAt(contractAddress, index,16368474).then(res=>{
console.log(res)
})
)
}
This runs into an error Error: Returned error: header not found
.I tried changing blocks but run into the same error . The error only resolves if I don't pass 16368474
but that uses the latest
block and that's not what I want . I tried the same with web3.py
. It runs into the same error. What am I doing wrong ? Is there an alternate way of getting storage ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码是有效的 - 问题是节点提供商不支持查询历史状态。
解决方案:使用支持存档节点的其他提供商,例如 Moralis 。
Your code is valid - the issue is that the node provider doesn't support querying historic states.
Solution: Use a different provider that supports archive node, e.g. Moralis.