Facet SDK is a TypeScript-based SDK that allows users to interact seamlessly with the Facet blockchain ecosystem, including functionalities like transaction creation and integration with viem
.
To install Facet SDK with npm:
npm install @0xfacet/sdk
Or with yarn:
yarn add @0xfacet/sdk
Initialize the SDK by importing Facet chains and clients.
import { walletL1FacetActions } from "@0xfacet/sdk/viem";
import { createWalletClient, http } from "viem";
const walletClient = createWalletClient({
chain: mainnet,
transport: http(),
}).extend(walletL1FacetActions);
const params = {
to: "0xReceiverAddress", // Required
data: "0x", // Optional
value: 0n, // Optional
};
const { l1TransactionHash, facetTransactionHash, fctMintAmount, fctMintRate } =
await walletClient.sendFacetTransaction(params);
console.log("L1 Transaction Hash:", l1TransactionHash);
console.log("Facet Transaction Hash:", facetTransactionHash);
console.log("FCT Mined:", fctMintAmount);
console.log("FCT Mint Rate:", fctMintRate);
-
Build: Compiles TypeScript files to JavaScript for distribution.
npm run build
-
Lint: Lints TypeScript files for consistent code quality.
npm run lint
-
Format: Formats code with Prettier.
npm run format
The SDK uses ESLint and Prettier for code quality and formatting. Run the following commands for linting and formatting:
npm run lint # Check for lint errors
npm run lint:fix # Auto-fix lint errors
npm run format # Format code with Prettier
Contributions are welcome! Please follow the code style guidelines, linting, and formatting rules before submitting a pull request. For major changes, please open an issue first.