linea-mcp
Version:
A Model Context Protocol server for interacting with the Linea blockchain
74 lines • 2.77 kB
TypeScript
import { PublicClient, Chain, Address, Hex, Transaction, TransactionReceipt, EstimateGasParameters, Abi, GetContractReturnType } from 'viem';
type NetworkName = 'mainnet' | 'testnet' | 'ethereum';
/**
* Service for interacting with blockchains using viem's PublicClient
*/
declare class BlockchainService {
private _client;
private network;
private chain;
/**
* Create a new BlockchainService instance
* @param network The network to connect to (mainnet, testnet, or ethereum)
*/
constructor(network?: NetworkName);
/**
* Get the current viem PublicClient instance
* @returns The PublicClient instance
*/
get client(): PublicClient;
/**
* Get the current viem Chain object
* @returns The Chain object
*/
get currentChain(): Chain;
/**
* Get the current network name
* @returns The network name (mainnet, testnet, or ethereum)
*/
get currentNetwork(): NetworkName;
/**
* Get the current block number
* @returns A promise that resolves to the current block number (bigint)
*/
getBlockNumber(): Promise<bigint>;
/**
* Get the balance of an address
* @param address The address (0x...) to check the balance of
* @returns A promise that resolves to the balance formatted as an Ether string
*/
getBalance(address: Address): Promise<string>;
/**
* Get a transaction by its hash
* @param txHash The transaction hash (0x...)
* @returns A promise that resolves to the transaction details or null if not found
*/
getTransaction(txHash: Hex): Promise<Transaction | null>;
/**
* Get a transaction receipt by its hash
* @param txHash The transaction hash (0x...)
* @returns A promise that resolves to the transaction receipt or null if not found/mined
*/
getTransactionReceipt(txHash: Hex): Promise<TransactionReceipt | null>;
/**
* Create a read-only contract instance
* @param address The contract address (0x...)
* @param abi The contract ABI
* @returns A viem Contract instance for read operations
*/
createContract(address: Address, abi: Abi): GetContractReturnType<Abi, PublicClient>;
/**
* Estimate gas for a transaction
* @param transaction The transaction parameters (matching viem's EstimateGasParameters)
* @returns A promise that resolves to the gas estimate (bigint)
*/
estimateGas(transaction: EstimateGasParameters): Promise<bigint>;
/**
* Get the current gas price
* @returns A promise that resolves to the current gas price (bigint)
*/
getGasPrice(): Promise<bigint>;
}
export default BlockchainService;
export type { NetworkName };
//# sourceMappingURL=blockchain.d.ts.map