Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ artifacts
.secret*

*.sw*

balances.csv
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"start": "concurrently \"cd api && npm start\" \"cd app && npm run dev\"",
"deploy": "npx hardhat run scripts/deployArchetype.ts --network sepolia",
"network": "npx hardhat node",
"verify": "npx hardhat verify 0x17a23A733d7B8206a4F950cFdDbdB56563Ce3b7b --network sepolia"
"verify": "npx hardhat verify 0x17a23A733d7B8206a4F950cFdDbdB56563Ce3b7b --network sepolia",
"withdraw": "npx hardhat run --network mainnet scripts/getWithdrawable.ts"
},
"repository": {
"type": "git",
Expand Down
45 changes: 29 additions & 16 deletions scripts/getWithdrawable.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
import { ethers, run } from "hardhat";
import fetch from 'node-fetch';
import { ethers } from "hardhat";
import fetch from "node-fetch";
import fs from "fs";
import path from "path";

const ZERO = "0x0000000000000000000000000000000000000000";

async function main() {
const contracts = await (await fetch('https://scatter-api.fly.dev/api/contracts')).json()
const contracts = await (await fetch("https://scatter-api.fly.dev/api/contracts")).json();

// Prepare to write to a CSV file
const filePath = path.join(__dirname, "balances.csv");
const header = "Contract Address,Owner Balance,Platform Balance\n";
fs.writeFileSync(filePath, header, { encoding: "utf8" });

let totalPlat = 0;
for (const contract of contracts.body) {
try {
const archetype = await ethers.getContractAt("Archetype", contract);
const balance = await archetype.ownerBalance();
const ownerBalance = ethers.utils.formatEther(balance.owner);
const platformBalance = ethers.utils.formatEther(balance.platform);
console.log(contract, "platform:", platformBalance, "owner:", ownerBalance);
totalPlat += Number(platformBalance);

let totalPlat = 0
for(const contract of contracts.body) {
// const archetype = Archetype.attach(contract);
try{
const archetype = await ethers.getContractAt("Archetype", contract);
const balance = await archetype.ownerBalance();
console.log(contract, "platform:", ethers.utils.formatEther(balance.platform), "owner:", ethers.utils.formatEther(balance.owner));
totalPlat += Number(ethers.utils.formatEther(balance.platform))
} catch(e) {
console.log(contract, "not Archetype");
continue
}
// Write the contract data to the CSV file
const line = `${contract},${ownerBalance},${platformBalance}\n`;
fs.appendFileSync(filePath, line, { encoding: "utf8" });
} catch (e) {
console.error(e);
console.log(contract, "not Archetype");
}
}

console.log("total platform:", totalPlat)
console.log("total platform:", totalPlat);
}

main()
Expand Down