Skip to content
This repository was archived by the owner on Aug 22, 2025. 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
37 changes: 37 additions & 0 deletions src/strategies/byosectest/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Strategy } from "../../types";
import { getAddress } from "@ethersproject/address";

export const author = "archethic-core";
export const version = "0.1.0";

const abi = [
"function getVotingPower(address account) view returns (uint256)"
];

export const strategy: Strategy = async (
space,
network,
provider,
addresses,
options,
snapshot
) => {
const blockTag = typeof snapshot === "number" ? snapshot : "latest";

const response = await Promise.all(
addresses.map(async (address: string): Promise<[string, number]> => {
try {
const votingPower: bigint = await provider.call({
to: options.address,
data: provider.encodeFunctionData(abi[0], [getAddress(address)])
}, blockTag);

return [address, Number(votingPower.toString())];
} catch (error) {
return [address, 0];
}
})
);

return Object.fromEntries(response);
};
18 changes: 18 additions & 0 deletions src/strategies/byosectest/strategy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "byosectest",
"author": "archethic-core",
"version": "0.1.0",
"about": "Strategy that uses getVotingPower(address) from the BYOSecTestToken contract on Polygon.",
"examples": [
{
"name": "default",
"strategy": {
"name": "byosectest",
"network": "137",
"params": {
"address": "0x7634E7a3f0B25b00CE63bBA19C76bB6284A9BfD0"
}
}
}
]
}