From 0435367544694ac3d63461f9e331388eed50f20f Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Fri, 7 Jul 2023 15:43:35 +0300 Subject: [PATCH] fix ethereum example --- docs/examples/ethers/block_by_timestamp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/examples/ethers/block_by_timestamp.js b/docs/examples/ethers/block_by_timestamp.js index eee35bf..7a0373d 100644 --- a/docs/examples/ethers/block_by_timestamp.js +++ b/docs/examples/ethers/block_by_timestamp.js @@ -1,4 +1,4 @@ -import {ethers} from 'https://unpkg.com/ethers@5.7.2/dist/ethers.esm.js' +import {ethers} from 'https://unpkg.com/ethers/dist/ethers.js' const URL = 'https://rpc.ankr.com/eth' @@ -6,6 +6,9 @@ const provider = await ethers.getDefaultProvider(URL) const latest = await provider.getBlock('latest') +/* + Find ethereum block by timestamp using binary search +*/ async function getBlockNumberByTimestamp(timestamp, low = 0, high = latest.number) { if(low + 1 == high) { return low