-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXPReward.ts
65 lines (51 loc) · 1.69 KB
/
XPReward.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import {
ethers,
JsonRpcProvider,
Contract,
Signer,
NonceManager,
} from "ethers";
import { processTypechainAbis } from "./process-typechain-abis";
import * as typechain from "../typechain-types";
import dotenv from "dotenv";
dotenv.config({ path: ".env" });
if (!process.env.WALLET_KEY_TESTNET) {
throw new Error("Provide Wallet Key");
}
const abiMap = processTypechainAbis(typechain, {
XPReward: "0x456fc3A1FD5f8E0df686b2151e001065d78eDE0c",
});
const provider = new JsonRpcProvider(`https://bartio.rpc.berachain.com/`);
const WALLET_KEY_TESTNET = process.env.WALLET_KEY_TESTNET as string;
const privateKey = WALLET_KEY_TESTNET;
const wallet = new ethers.Wallet(privateKey, provider);
const signer: Signer = new NonceManager(wallet);
const xpReward = new Contract(
abiMap.XPReward.defaultAddress,
abiMap.XPReward.abi,
signer
);
async function runInteractions() {
console.log("CLAIMING __ XP");
let tx = await xpReward.claimXP();
tx.wait();
console.log("CLAIMED __ XP");
console.log("UPDATE __ TIME __ SIGNED __ XP");
tx = await xpReward.updateTimeSigned();
tx.wait();
console.log("UPDATED __ TIME __ SIGNED __ XP");
console.log("UPDATE __ TIME __ UPDATED __ XP");
tx = await xpReward.updateTimeUpdated();
tx.wait();
console.log("UPDATED __ TIME __ UPDATED __ XP");
}
async function main() {
console.log("Function executed at", new Date().toLocaleTimeString());
await runInteractions();
}
// Set interval to run the function every 3 minutes (180,000 milliseconds)
const intervalId = setInterval(main, 180000);
setTimeout(() => {
clearInterval(intervalId);
console.log("Function execution stopped after 30 minutes.");
}, 1800000); // 30 minutes in milliseconds