1use alloy_primitives::{Address, Bytes, B256, U256};
2use alloy_rpc_types_anvil::{Forking, Metadata};
3use jsonrpsee::{core::RpcResult, proc_macros::rpc};
4
5#[rpc(server, namespace = "hardhat")]
8pub trait HardhatApi {
9 #[method(name = "hardhat_dropTransaction")]
13 async fn hardhat_drop_transaction(&self, tx_hash: B256) -> RpcResult<bool>;
14
15 #[method(name = "impersonateAccount")]
17 async fn hardhat_impersonate_account(&self, address: Address) -> RpcResult<()>;
18
19 #[method(name = "getAutomine")]
21 async fn hardhat_get_automine(&self) -> RpcResult<bool>;
22
23 #[method(name = "metadata")]
25 async fn hardhat_metadata(&self) -> RpcResult<Metadata>;
26
27 #[method(name = "mine")]
29 async fn hardhat_mine(&self, blocks: Option<U256>, interval: Option<U256>) -> RpcResult<()>;
30
31 #[method(name = "reset")]
33 async fn hardhat_reset(&self, fork: Option<Forking>) -> RpcResult<()>;
34
35 #[method(name = "setBalance")]
37 async fn hardhat_set_balance(&self, address: Address, balance: U256) -> RpcResult<()>;
38
39 #[method(name = "setCode")]
41 async fn hardhat_set_code(&self, address: Address, code: Bytes) -> RpcResult<()>;
42
43 #[method(name = "setCoinbase")]
45 async fn hardhat_set_coinbase(&self, address: Address) -> RpcResult<()>;
46
47 #[method(name = "setLoggingEnabled")]
49 async fn hardhat_set_logging_enabled(&self, enabled: bool) -> RpcResult<()>;
50
51 #[method(name = "setMinGasPrice")]
53 async fn hardhat_set_min_gas_price(&self, gas_price: U256) -> RpcResult<()>;
54
55 #[method(name = "setNextBlockBaseFeePerGas")]
57 async fn hardhat_set_next_block_base_fee_per_gas(
58 &self,
59 base_fee_per_gas: U256,
60 ) -> RpcResult<()>;
61
62 #[method(name = "setPrevRandao")]
64 async fn hardhat_set_prev_randao(&self, prev_randao: B256) -> RpcResult<()>;
65
66 #[method(name = "setNonce")]
68 async fn hardhat_set_nonce(&self, address: Address, nonce: U256) -> RpcResult<()>;
69
70 #[method(name = "setStorageAt")]
72 async fn hardhat_set_storage_at(
73 &self,
74 address: Address,
75 slot: U256,
76 value: B256,
77 ) -> RpcResult<()>;
78
79 #[method(name = "stopImpersonatingAccount")]
81 async fn hardhat_stop_impersonating_account(&self, address: Address) -> RpcResult<()>;
82}