Skip to content

Commit

Permalink
npm install alchemy-sdk & web3
Browse files Browse the repository at this point in the history
  • Loading branch information
uwezukwechibuzor committed Sep 27, 2023
1 parent e5b9bab commit 1c908a7
Show file tree
Hide file tree
Showing 3 changed files with 2,573 additions and 16 deletions.
30 changes: 30 additions & 0 deletions backend/data/chainQueries/ethereum/inex.js
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);
});
Loading

0 comments on commit 1c908a7

Please sign in to comment.