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

feat: add function to fetch last X txs from a specific address #351

Closed
wants to merge 1 commit into from
Closed
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
49 changes: 49 additions & 0 deletions packages/sdk/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ethers } from "ethers";
import { formatEther } from "ethers/lib/utils";
import { ServiceBridge } from "../src/service_bridge";
import { delay } from "../src/utils";
import { resolve } from "path";
import dotenv from "dotenv";
dotenv.config({ path: resolve(__dirname, "../.env.test") });

async function main() {
const l1Url: string = process.env.L1_URL!;
const l2Url: string = process.env.L2_URL!;
const l1ChainId: number = parseInt(process.env.L1_CHAIN_ID!);
const l2ChainId: number = parseInt(process.env.L2_CHAIN_ID!);

const l1RpcProvider = new ethers.providers.JsonRpcProvider(l1Url);
const l2RpcProvider = new ethers.providers.JsonRpcProvider(l2Url);
const l1Wallet = new ethers.Wallet(
"0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
l1RpcProvider,
);
const l2Wallet = new ethers.Wallet(
"0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
l2RpcProvider,
);

const l1balance = await l1Wallet.getBalance();
console.log("L1 balancee: ", l1balance);

const serviceBridge = new ServiceBridge({
l1SignerOrProvider: l1Wallet, // l1 signer
l2SignerOrProvider: l2Wallet, // l2 signer
l1ChainId,
l2ChainId,
});

const test = await serviceBridge.getLastTransactionsFromAddress(
l1Wallet.address,
10,
);

console.log(l1Wallet.address);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Loading
Loading