How To Use Presto with web3.js
npm install web3const Web3 = require('web3');

Last updated
npm install web3const Web3 = require('web3');

Last updated
const rpcEndpoint = '<RPC URL from the chain>'; // Replace with your custom RPC endpoint
const web3 = new Web3(rpcEndpoint);// Get the latest block number
web3.eth.getBlockNumber()
.then(blockNumber => {
console.log('Latest Block Number:', blockNumber);
})
.catch(error => {
console.error('Error:', error);
});
// Get balance of an address
const address = '0x1234567890abcdef...'; // Replace with the desired address
web3.eth.getBalance(address)
.then(balance => {
console.log('Balance of', address + ':', balance);
})
.catch(error => {
console.error('Error:', error);
});
// Send a transaction
const from = '0x9876543210fedcba...'; // Replace with the sender's address
const to = '0xabcdef1234567890...'; // Replace with the recipient's address
const value = web3.utils.toWei('1', 'ether'); // Replace with the desired value
web3.eth.sendTransaction({ from, to, value })
.then(transactionHash => {
console.log('Transaction Hash:', transactionHash);
})
.catch(error => {
console.error('Error:', error);
});