@0xfacet/sdk
Version:
A toolkit for Facet blockchain integration.
43 lines (42 loc) • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFctMintRate = void 0;
const viem_1 = require("viem");
const addresses_1 = require("../constants/addresses");
const viem_2 = require("../viem");
/**
* Retrieves the current FCT mint rate from the L1 block contract.
*
* @param l1ChainId - The chain ID of the L1 network (1 for Ethereum mainnet, 11155111 for Sepolia testnet)
* @returns A Promise that resolves to the current FCT mint rate as a bigint
*/
const getFctMintRate = async (l1ChainId) => {
if (l1ChainId !== 1 && l1ChainId !== 11155111) {
throw new Error("Invalid chain id");
}
const facetPublicClient = (0, viem_1.createPublicClient)({
chain: l1ChainId === 1 ? viem_2.facetMainnet : viem_2.facetSepolia,
transport: (0, viem_1.http)(),
});
const fctMintRate = await facetPublicClient.readContract({
address: addresses_1.L2_L1_BLOCK_CONTRACT,
abi: [
{
inputs: [],
name: "fctMintRate",
outputs: [
{
internalType: "uint128",
name: "",
type: "uint128",
},
],
stateMutability: "view",
type: "function",
},
],
functionName: "fctMintRate",
});
return fctMintRate;
};
exports.getFctMintRate = getFctMintRate;