-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5b9bab
commit 1c908a7
Showing
3 changed files
with
2,573 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Network, Alchemy } from "alchemy-sdk"; | ||
import Web3 from "web3"; | ||
|
||
// Initialize a Web3 instance (connect to an Ethereum node if needed) | ||
const web3 = new Web3(); | ||
|
||
const settings = { | ||
apiKey: "iHiSvMYKjRZEuwF_ma9IecHZUjiHiagG", | ||
network: Network.ETH_MAINNET, | ||
}; | ||
|
||
const alchemy = new Alchemy(settings); | ||
|
||
// Get the latest block | ||
alchemy.core | ||
.getBlock("latest") | ||
.then(async (block) => { | ||
//console.log("Latest Block:", block); | ||
|
||
// Fetch transaction details for each transaction in the block | ||
for (const txHash of block.transactions) { | ||
const transaction = await alchemy.core.getTransaction(txHash); | ||
//console.log("Transaction:", transaction.value._hex); | ||
const decimalValue = web3.utils.hexToNumberString("0x06ef075cb1e307f0"); | ||
console.log(`Decimal Value: ${decimalValue}`); | ||
} | ||
}) | ||
.catch((error) => { | ||
console.error("Error:", error); | ||
}); |
Oops, something went wrong.