Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
GalaxySciTech committed Nov 9, 2023
1 parent 238ae07 commit e4d1c66
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions src/service/zero/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,29 @@ import endpointABI from "../../abi/endpointABI.json";

// const account = privateKeyToAccount(`0x${process.env.PRIVATE_KEY}`);

const endpoint = "0xD4449Bf3f8E6a1b3fb5224F4e1Ec4288BD765547";
const subnetEndpointContract = {
address: "0xD4449Bf3f8E6a1b3fb5224F4e1Ec4288BD765547",
abi: endpointABI,
};

const devnetEndpointContract = {
address: "0xD4449Bf3f8E6a1b3fb5224F4e1Ec4288BD765547",
abi: endpointABI,
};
const xdcdevnet = {
id: 551,
name: "XDC Devnet",
network: "XDC Devnet",
nativeCurrency: {
decimals: 18,
name: "XDC",
symbol: "XDC",
},
rpcUrls: {
public: { http: ["https://devnetstats.apothem.network/devnet"] },
default: { http: ["https://devnetstats.apothem.network/devnet"] },
},
};
const xdcsubnet = {
id: 4865,
name: "XDC Subnet",
Expand All @@ -31,24 +52,36 @@ const xdcsubnet = {
// chain: xdcsubnet,
// transport: http(),
// });
export const publicClient = createPublicClient({
export const subnetPublicClient = createPublicClient({
chain: xdcsubnet,
transport: http(),
});

export const devnetPublicClient = createPublicClient({
chain: xdcdevnet,
transport: http(),
});

export const getBlock = async () => {
const blockNumber = await publicClient.getBlockNumber();
const blockNumber = await subnetPublicClient.getBlockNumber();
console.log("viem:" + blockNumber);
};

export const validateTransactionProof = async () => {
return;
};

export const getChainIdFromParentnet = async () => {
const reads = devnetPublicClient.multicall({
contracts: [
{ ...(devnetEndpointContract as any), functionName: "totalSupply" },
],
});
};

export const sync = async () => {
const logs = await publicClient.getContractEvents({
address: endpoint as any,
abi: endpointABI as any,
const logs = await subnetPublicClient.getContractEvents({
...(subnetEndpointContract as any),
fromBlock: BigInt(0),
eventName: "Packet",
});
Expand Down

0 comments on commit e4d1c66

Please sign in to comment.