UNPKG

@0xfacet/sdk

Version:

A toolkit for Facet blockchain integration.

43 lines (42 loc) 2.76 kB
import { Abi, Account, Chain, Client, ContractFunctionArgs, ContractFunctionName, Hex, Transport, WriteContractParameters, WriteContractReturnType } from "viem"; /** * Executes a write operation on a smart contract through the Facet infrastructure. * * This function encodes the function call data, builds a Facet transaction, and sends it * to the blockchain. It handles the complexity of interacting with the Facet protocol * while maintaining a similar interface to viem's standard contract writing functions. * * @template {Chain | undefined} chain - The blockchain chain type * @template {Account | undefined} account - The account type * @template {Abi | readonly unknown[]} abi - The contract ABI * @template {ContractFunctionName<abi, "nonpayable" | "payable">} functionName - The contract function name * @template {ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>} args - The function arguments * @template {Chain | undefined} chainOverride - Optional chain override * * @param {Client<Transport, chain, account>} client - The viem client instance * @param {WriteContractParameters<abi, functionName, args, chain, account, chainOverride>} parameters - The contract write parameters * @param {abi} parameters.abi - The contract ABI * @param {account} [parameters.account] - The account to use (defaults to client.account) * @param {Address} parameters.address - The contract address * @param {args} parameters.args - The function arguments * @param {string} [parameters.dataSuffix] - Optional data to append to the transaction data * @param {functionName} parameters.functionName - The name of the function to call * @param {Hex} [parameters.mineBoost] - Optional hex value to increase FCT mining amount * * @returns {Promise<WriteContractReturnType>} The transaction hash * * @throws {Error} If no account is provided or found in the client * @throws {BaseError} With contract context if the transaction fails * * @example * const hash = await writeFacetContract(client, { * address: '0x...', * abi: MyContractABI, * functionName: 'setName', * args: ['New Name'], * mineBoost: '0x1234' // Optional: increase FCT mining amount * }) */ export declare function writeFacetContract<chain extends Chain | undefined, account extends Account | undefined, const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "nonpayable" | "payable">, args extends ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>, chainOverride extends Chain | undefined>(client: Client<Transport, chain, account>, parameters: WriteContractParameters<abi, functionName, args, chain, account, chainOverride> & { mineBoost?: Hex; }): Promise<WriteContractReturnType>;