Skip to content

Commit

Permalink
Create Web3.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 26, 2024
1 parent 262410e commit 280bb33
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Web3 = require('web3');

class Web3Utils {
constructor(providerUrl) {
this.web3 = new Web3(new Web3.providers.HttpProvider(providerUrl));
}

async getBlockNumber() {
return this.web3.eth.getBlockNumber();
}

async getTransactionCount(address) {
return this.web3.eth.getTransactionCount(address);
}

async getBalance(address) {
return this.web3.eth.getBalance(address);
}

async sendTransaction(tx) {
return this.web3.eth.sendTransaction(tx);
}

async getTransactionReceipt(txHash) {
return this.web3.eth.getTransactionReceipt(txHash);
}
}

module.exports = Web3Utils;

0 comments on commit 280bb33

Please sign in to comment.