- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 BNB 中计算 BEP20 代币的价格。
我检查了 poocoin 和 pancakeswap 他们如何计算价格。正如我所见,他们通过 web3.js 不断调用 bsc-dataseed,但我还没有找到解决方案。
我的调查现状:
// Request params
{
"jsonrp": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 53,
"method": "eth_call",
"params": [
{
"to": "0x1ee38d535d541c55c9dae27b12edf090c608e6fb",
"data": "0x252dba420000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000580000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000006800000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000078000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000880000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000009800000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a800000000000000000000000000000000000000000000000000000000000000b000000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000d000000000000000000000000000000000000000000000000000000000000000d800000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000e800000000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000f8000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001080000000000000000000000000000000000000000000000000000000000000110000000000000000000000000003ff6c83226cdb10c7a42a2c54c67d63a135ab69000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000003fc20bdafdac6b2ae8f7f5f885f0819c2b968f0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000008b018585d4949ae4714f057b66b8b033408bfa6000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000012c8db147721ac1e3e54e9ff73d99ef0ee4b1725000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000001b96b92314c44b159149f7e0303511fb2fc4774f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000020bcc3b8a0091ddac2d0bc30f68e6cbb97de59cd000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000002c5d712cf39eaebc1ef2d1281eb48a70dcd34d49000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000003ab77e40340ab084c3e23be8e5a6f7afed9d41dc000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000003b872e6b1633f060680cf9c277b43dd1e254e564000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000056c77d59e82f33c712f919d09fceddf49660a829000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000006f656513f6e8eae19b6dc30cd372dd6ba4b5543a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000070d8929d04b60af4fb9b58713ebcf18765ade422000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000007246d6ea86d34af343f03cc1eb952a4f98467a4e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000007380e10f5c5f9dff4857de3cf9c39bb16f4c6dcf000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000007561eee90e24f3b348e1087a005f78b4c8453524000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000088c4bcf826410a81b58bc9b79a17641b443dc52e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac0000000000000000000000000000000000000000000000000000000000000000000000000000000092ee07c591c26775b4d31259d5417e00553e857c000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac000000000000000000000000000000000000000000000000000000000000000000000000000000009adc6fb78cefa07e13e9294f150c1e8c1dd566c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000cc6b11de64dce6e5052a84b67cbbfd210ed530f7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000d1f12370b2ba1c79838337648f820a87edf5e1e6000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000b3c4217ab2b265bf8c69718d280e3708b5e50577000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000b8875e207ee8096a929d543c9981c9586992eacb000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000c15fa3e22c912a276550f3e5fe3b0deb87b55acd000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000cee09ae86a78ce0cea3a4ea8cced5d41c0468e67000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000d9a0d1f5e02de2403f68bb71a15f8847a854b494000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000e7cc44de50b54906a9c1c48240650be2766481fc000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000fb7deb2236815222113d949d935cca4901531677000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000000000000000000000000000fa3107bca2ff6db4131bcd62b598cb00d9087f58000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000040902f1ac00000000000000000000000000000000000000000000000000000000"
},
"latest"
]
}
据我所知
0x1ee38d535d541c55c9dae27b12edf090c608e6fb
是一个包含
multicall
的合约方法。数据的前 10 个字符 (0x252dba42) 是
aggregate
方法。但是数据的剩余部分是什么?
aggregate
的合约 ABI方法:
{
"constant": true,
"inputs": [
{
"components": [
{"name": "target","type": "address"},
{"name": "callData","type": "bytes"}
],
"name": "calls",
"type": "tuple[]"
}
],
"name": "aggregate",
"outputs": [
{
"name": "blockNumber",
"type": "uint256"
},
{
"name": "returnData",
"type": "bytes[]"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
问题:
最佳答案
关于是否可以从 web3 计算代币价格的问题的答案在这里:https://ethereum.stackexchange.com/questions/98302/how-can-we-get-the-current-spot-price-for-a-bep20-token-used-web3
但是:部分回答您的问题。eth_blockNumber
用于获取在最新块中传递的交易并在此处显示值:
eth_call
使用方法 sha3 0x252dba42
调用对应于 aggregator
你提到的功能。代码如下:
contract Multicall {
struct Call {
address target;
bytes callData;
}
function aggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes[] memory returnData) {
blockNumber = block.number;
returnData = new bytes[](calls.length);
for(uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);
require(success);
returnData[i] = ret;
}
}
如您所见,这只是执行多个 eth_call
calls[i].target.call(calls[i].callData);
的一种方式这意味着它是做很多事情的有效方式
eth_call
通过只调用 Web3 一次,因此是为了大幅增加执行时间。
eth_call
包含在更大的结构中。
0x252dba42
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000000000000000000000000000000000000000000d
00000000000000000000000000000000000000000000000000000000000001a0
0000000000000000000000000000000000000000000000000000000000000220
00000000000000000000000000000000000000000000000000000000000002a0
0000000000000000000000000000000000000000000000000000000000000320
00000000000000000000000000000000000000000000000000000000000003a0
0000000000000000000000000000000000000000000000000000000000000420
00000000000000000000000000000000000000000000000000000000000004a0
0000000000000000000000000000000000000000000000000000000000000520
00000000000000000000000000000000000000000000000000000000000005c0
0000000000000000000000000000000000000000000000000000000000000660
0000000000000000000000000000000000000000000000000000000000000700
0000000000000000000000000000000000000000000000000000000000000780
0000000000000000000000000000000000000000000000000000000000000800
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
0902f1ac > getReserves() -> pancake
00000000000000000000000000000000000000000000000000000000
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
d21220a7 > token1 -> pancake
00000000000000000000000000000000000000000000000000000000
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
18160ddd > totalSupply -> swole
00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
313ce567 > decimals > swole
00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
18160ddd > totalSupply > swole
00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
95d89b41 > symbol > swole
00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
06fdde03 > name > swole
00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000024
70a08231 > balanceOf > swole
00000000000000000000000000000000000000000000000000000000
0000dead00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000024
70a08231 > balanceOf > swole
00000000000000000000000000000000000000000000000000000000
00000ded00000000000000000000000000000000000000000000000000000000
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000024
70a08231 > balanceOf > pancake
00000000000000000000000000000000000000000000000000000000
0000000100000000000000000000000000000000000000000000000000000000
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
0902f1ac > getReserves > pancake
00000000000000000000000000000000000000000000000000000000
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
d21220a7 > Token1 (pancake)
00000000000000000000000000000000000000000000000000000000
000000000000000000000000b443d19e5448c8a58916ca8e0a33c41212668ad3
0000000000000000000000000000000000000000000000000000000000000040
0000000000000000000000000000000000000000000000000000000000000004
18160ddd > TotalSupply
00000000000000000000000000000000000000000000000000000000
如果你想找到sha3所涉及的方法的名称,你可以引用这个网站:
https://pkg.go.dev/github.com/y2labs-0sh/dada-api/contractabi
eth_call
它会给你:
0x
000000000000000000000000000000000000000000000000000000000071f9b8
0000000000000000000000000000000000000000000000000000000000000040
000000000000000000000000000000000000000000000000000000000000000d
00000000000000000000000000000000000000000000000000000000000001a0
0000000000000000000000000000000000000000000000000000000000000220
0000000000000000000000000000000000000000000000000000000000000260
00000000000000000000000000000000000000000000000000000000000002a0
00000000000000000000000000000000000000000000000000000000000002e0
0000000000000000000000000000000000000000000000000000000000000320
00000000000000000000000000000000000000000000000000000000000003a0
0000000000000000000000000000000000000000000000000000000000000420
0000000000000000000000000000000000000000000000000000000000000460
00000000000000000000000000000000000000000000000000000000000004a0
00000000000000000000000000000000000000000000000000000000000004e0
0000000000000000000000000000000000000000000000000000000000000560
00000000000000000000000000000000000000000000000000000000000005a0
0000000000000000000000000000000000000000000000000000000000000060
0000000000000000000000000000000000000000000000000d04526e1cee610a
0000000000000000000000000000000000000000096f9d05ebe63c03e58cc07a
0000000000000000000000000000000000000000000000000000000060a16f16
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000000000000000000000000a968163f0a57b400000
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000012 > decimals
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000001431e0fae6d7217caa0000000
0000000000000000000000000000000000000000000000000000000000000060
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000004
534f474500000000000000000000000000000000000000000000000000000000 > SOGE
0000000000000000000000000000000000000000000000000000000000000060
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000000000000000000000000000000000000000000a
53776f6c6520446f676500000000000000000000000000000000000000000000 > Swole Doge
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000060
0000000000000000000000000000000000000000000000000d04526e1cee610a
0000000000000000000000000000000000000000096f9d05ebe63c03e58cc07a
0000000000000000000000000000000000000000000000000000000060a16f16
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000f5318b3941b3f1239dd910c941bbe2259f32311b
0000000000000000000000000000000000000000000000000000000000000020
000000000000000000000000000000000000000000000a968163f0a57b400000
另请注意,poocoin 每次都使用不同的 token 地址进行多个 eth_call。
eth_call
用于确定代币价格。不过如果你发现了,我会很感兴趣的。
关于node.js - 如何获得 BEP20 代币的价格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67448627/
我用运行 Node node --debug app OR node --debug-brk app 它有反应 debugger listening on port 5858 Express serv
这个问题在这里已经有了答案: What is the difference between (int *i) and (int* i) in context of both C and C++? [
我有一个应用程序,它通过消息队列将数据库写入命令分派(dispatch)给工作人员(数量非常大),因此无法保证它们的接收顺序。 我有两个 Node ,例如“Account”和“Media”。在此假设的
有没有办法在调用 ts-node 时将选项传递给 Node ?我正在尝试在 Node 中使用一个实验性功能,如果它能与 ts-node 一起使用,那就太好了。 这就是我目前正在做的事情: ts-nod
我有一个容器化的Node应用程序,它在DigitalOcean服务器上运行。当我更新服务器上的应用程序时,该应用程序必须关闭一小段时间。为了能够更新应用程序并避免停机,我目前正在阅读零停机时间部署/蓝
我正在编写一个 Node.js 应用程序。我正在使用 request 和 Cheerio 加载一组 URL 并获取该网站的大量信息,现在假设我想要获取的只是标题: var urls = {"url_1
如果不弹出以下错误,我无法安装任何 Node.js 模块。错误代码引用package.json文件。如果知道为什么会发生这种情况,我们将不胜感激。 最佳答案 这些不是错误,它们只是警告。一切都应该如此
如果我运行(从我的项目目录中): supervisor javascripts/index.js 我得到:/usr/bin/env: Node :没有这样的文件或目录 如果我运行: node java
我已遵循使用 Node-Inspector 的所有步骤 但是当我打开应用程序时,我在控制台上看不到任何脚本或日志。 我的应用程序在端口 4000 上运行。我认为唯一可能发生冲突的是端口 8080 上的
我在android中使用rxjava2,有时会遇到这样的问题: Observable.fromArray( // maybe a list about photo url in SD
我目前正在使用 Node 光纤来编写同步服务器端代码。我主要通过 try-catch block 进行错误处理,但外部库或其他小部分异步代码中总是有可能发生错误。我正在考虑使用新的域功能来尝试将这些错
看起来node-debug是node-inspector周围的一个shell?分别什么时候应该使用? 最佳答案 如果您安装node-debug,您只能访问node-debug命令。 如果您安装node
我目前正在代理后面工作,该代理不允许我执行此命令的 HTTP GET 请求阶段: Node node-sass/scripts/build.js 请求阶段: gyp http GET https://
听说node js可以用在服务端。我以前用过jsp。 jsp页面内部的java代码对客户端是不可见的。如果 Node js 只是 javascript,那么它如何对客户端不可见? 最佳答案 首先,No
我正在为 Node native 插件从 node-waf 构建迁移到 node-gyp 构建系统。 node-gyp 说它支持多个目标版本,但我在使用 node-gyp 时找不到如何指定目标 Nod
给定一个 $node ,我正在尝试在以下两种输出该 $node 的方式之间做出决定。 要么 $output = theme('node', $node); 或 node_build_content($
如果package.json中的窗口A打开一个新窗口B,node-main如何访问它?这是我的代码: package.json { "main": "index.html",
我试图在我的 xml 中的特定节点 ( ) 之前插入一个注释节点。这是它的方法: function test(xmlResponse) { var parser = new DOMParse
我正在尝试做npm install wrtc使用 Node 版本 16.14.0 但这还没有完成。它在给npm error code 1所以我试图将 Node 版本更改为以前的 lts 14.19.0
当我在 Visual Studio 中运行 Node.js 应用程序时,我收到以下消息:DeprecationWarning: 'node --debug' 和 'node --debug-brk'
我是一名优秀的程序员,十分优秀!