Hardhat Plugin API Reference
The Hardhat plugin injects hre.midl, which provides a programmatic interface for deploying and interacting with contracts in a Bitcoin-EVM hybrid environment using Hardhat and MIDL tools.
Methods
initialize
initialize(accountIndex?: number): Promise<Config>Initializes the environment and sets up the wallet and config.
deploy
deploy(
name: string,
args?: unknown[],
options?: DeployContractOptions,
overrides?: DeployContractIntentionOverrides
): Promise<{ address: Address; abi: any[] } | DeploymentData>Adds a deployment intention. If the contract is already deployed, returns the stored deployment data.
get
get(name: string): Promise<DeploymentData | null>Retrieves deployment information for a contract by name.
read
read(name: string, functionName: string, args?, options?): Promise<unknown>Reads a contract method using the current deployment address.
write
write(
name: string,
functionName: string,
args?,
evmTransactionOverrides?,
options?
): Promise<TransactionIntention>Adds a contract write intention (EVM call). options maps to the intention overrides (for example, deposit).
execute
execute(options?): Promise<[string, `0x${string}`[]] | null>Finalizes and broadcasts the BTC and EVM transactions. Returns BTC tx id and EVM tx hashes (or null if there are no intentions).
save
save(name: string, { abi, txId, address }): Promise<void>Saves deployment information to disk.
delete
delete(name: string): Promise<void>Deletes deployment information for a contract by name.
Properties
- account:
Account— The default account (requiresinitialize()). - evm.address:
string— The EVM address for the default account (requiresinitialize()).