Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show wallet information #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion arbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path');
const readlineSync = require('readline-sync');
const moment = require('moment');
const T3RN_ABI = require('./contracts/ABI');
const { displayHeader } = require('./utils/display');
const { displayHeader, createTable } = require('./utils/display');
const { transactionData, delay } = require('./chains/arbt/helper');
const { getAmount } = require('./chains/arbt/api');

Expand Down Expand Up @@ -34,6 +34,30 @@ const CONTRACT_ADDRESS = T3RN_ABI.at(-1).CA_ARBT;
process.exit(0);
}

console.log(`\n`)
console.log(`ARB Sepolia balance & Possible transactions (if minimum amount 0.01 ETH) `.yellow)

let wallets = [];
for (const PRIVATE_KEY of PRIVATE_KEYS) {
const wallet = new Wallet(PRIVATE_KEY, provider);
const balance = await provider.getBalance(wallet.address);
const balanceInEth = ethers.formatUnits(balance, 'ether');

// calculate how much possible transactions
const numberOfTx = Math.floor(balanceInEth / 0.01);

wallets.push({
address: wallet.address.slice(0, 8) + '...' + wallet.address.slice(-6),
balance: parseFloat(balanceInEth).toFixed(3) + ' ETH',
tx: numberOfTx
});
}
const table = await createTable(wallets);
console.log(table);
console.log(`The number of possible transactions does not include gas fees`.yellow);

console.log(`\n`)

const numTx = readlineSync.questionInt(
'🔄 How many times you want to swap or bridge? '
);
Expand Down
26 changes: 25 additions & 1 deletion opsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path');
const readlineSync = require('readline-sync');
const moment = require('moment');
const T3RN_ABI = require('./contracts/ABI');
const { displayHeader } = require('./utils/display');
const { displayHeader, createTable } = require('./utils/display');
const { transactionData, delay } = require('./chains/opsp/helper');
const { getAmount } = require('./chains/opsp/api');

Expand Down Expand Up @@ -34,6 +34,30 @@ const CONTRACT_ADDRESS = T3RN_ABI.at(-1).CA_OPSP;
process.exit(0);
}

console.log(`\n`)
console.log(`OP Sepolia balance & Possible transactions (if minimum amount 0.01 ETH) `.yellow)

let wallets = [];
for (const PRIVATE_KEY of PRIVATE_KEYS) {
const wallet = new Wallet(PRIVATE_KEY, provider);
const balance = await provider.getBalance(wallet.address);
const balanceInEth = ethers.formatUnits(balance, 'ether');

// calculate how much possible transactions
const numberOfTx = Math.floor(balanceInEth / 0.01);

wallets.push({
address: wallet.address.slice(0, 8) + '...' + wallet.address.slice(-6),
balance: parseFloat(balanceInEth).toFixed(3) + ' ETH',
tx: numberOfTx
});
}
const table = await createTable(wallets);
console.log(table);
console.log(`The number of possible transactions does not include gas fees`.yellow);

console.log(`\n`)

const numTx = readlineSync.questionInt(
'🔄 How many times you want to swap or bridge? '
);
Expand Down
3 changes: 2 additions & 1 deletion package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"colors": "^1.4.0",
"ethers": "^6.13.2",
"moment": "^2.30.1",
"readline-sync": "^1.4.10"
"readline-sync": "^1.4.10",
"cli-table3": "^0.6.5"
}
}
24 changes: 23 additions & 1 deletion utils/display.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require('colors');
const Table = require('cli-table3');

function displayHeader() {
process.stdout.write('\x1Bc');
Expand All @@ -10,4 +11,25 @@ function displayHeader() {
console.log();
}

module.exports = { displayHeader };
async function createTable(wallets) {
const table = new Table({
head: ['Wallet', 'Balance', 'Possible Tx'],
style: {
head: ['green'],
},
colWidths: [20, 15, 15],
});

for (const wallet of wallets) {
table.push([
wallet.address,
wallet.balance,
wallet.tx
]);
}

return table.toString();
}

module.exports = { displayHeader, createTable };