@parabolfi/core
Version:
Core utilities for Parabol SDK
66 lines • 2.92 kB
TypeScript
import { Hex, PrivateKeyAccount } from "viem";
import { RawTransaction, TransactionParams } from "../types/transaction";
import { Transactions } from "../transactions";
import { SupportedChainId } from "../config/global";
/**
* Performs a static call to a smart contract without creating a transaction.
*
* This function simulates the execution of a transaction on the blockchain
* without actually submitting it. It's useful for reading data from smart
* contracts or estimating gas costs.
*
* @param rawTx - The raw transaction object containing the call details.
* @param account - The private key account.
*
* @returns A promise that resolves to the result of the static call.
*
* @throws {Error} If the chain ID is not supported.
* @throws {Error} If the static call fails or returns no data.
*
* @example
* const rawTx = {
* chainId: 1,
* data: "0x...",
* to: "0x..."
* };
* const account = privateKeyToAccount("0x...");
* const result = await callStatic(rawTx, account);
*/
export declare function callStatic(rawTx: RawTransaction, account: PrivateKeyAccount): Promise<Hex>;
/**
* Creates a raw transaction object for a given transaction type and parameters.
*
* @template T - The specific transaction type extending Transactions enum.
* @param {T} transactionType - The type of transaction to create.
* @param {TransactionParams<T>} params - The parameters for the transaction.
* @param {SupportedChainId} chainId - The ID of the blockchain network.
* @returns {Promise<RawTransaction>} A promise that resolves to the raw transaction object.
* @throws {ParabolSDKError} If the chain ID is not supported or if the transaction type is invalid.
*
* @example
* const rawTx = await createRawTx(Transactions.Lend, lendParams, SupportedChainId.MAINNET);
*/
export declare function createRawTx<T extends Transactions>(transactionType: T, params: TransactionParams<T>, chainId: SupportedChainId): Promise<RawTransaction>;
/**
* Sends a transaction to the blockchain using the provided raw transaction data and account.
*
* @param {RawTransaction} rawTx - The raw transaction object containing transaction details.
* @param {PrivateKeyAccount} account - The private key account used to sign and send the transaction.
*
* @returns {Promise<Hex>} A promise that resolves to the transaction hash as a hexadecimal string.
*
* @throws {Error} If the chain ID is not supported.
* @throws {Error} If there's an error during the gas estimation or transaction sending process.
*
* @example
* const rawTx = {
* to: '0x1234...',
* data: '0xabcd...',
* chainId: 324 as SupportedChainId
* };
* const account = privateKeyToAccount('0x...');
* const txHash = await sendTx(rawTx, account);
* console.log('Transaction sent:', txHash);
*/
export declare function sendTx(rawTx: RawTransaction, account: PrivateKeyAccount): Promise<Hex>;
//# sourceMappingURL=transaction.d.ts.map