diff --git a/include/ethyl/provider.hpp b/include/ethyl/provider.hpp index 3b4e3cd..09c14a8 100644 --- a/include/ethyl/provider.hpp +++ b/include/ethyl/provider.hpp @@ -93,6 +93,14 @@ struct Provider : public std::enable_shared_from_this { void evm_snapshot_async(json_result_callback cb); bool evm_revert(std::string_view snapshotId); + // Enables or disables, based on the single boolean argument, the automatic + // mining of new blocks with each new transaction submitted to the network. + // You can use hardhat_getAutomine to get the current value. + bool evm_setAutomine(bool enable); + + // Force a block to be mined. Takes no parameters. Mines a block independent + // of whether or not mining is started or stopped. + bool evm_mine(); uint64_t evm_increaseTime(std::chrono::seconds seconds); std::optional getTransactionByHash(std::string_view transactionHash); diff --git a/src/provider.cpp b/src/provider.cpp index 8d85737..79f651a 100644 --- a/src/provider.cpp +++ b/src/provider.cpp @@ -341,6 +341,18 @@ void Provider::evm_snapshot_async(json_result_callback cb) { makeJsonRpcRequest("evm_snapshot", params, std::move(cb)); } +bool Provider::evm_setAutomine(bool enable) { + nlohmann::json params = nlohmann::json::array(); + params.push_back(enable); + std::optional result = makeJsonRpcRequest("evm_setAutomine", params); + return result.has_value(); +} + +bool Provider::evm_mine() { + std::optional result = makeJsonRpcRequest("evm_mine", nlohmann::json::array()); + return result.has_value(); +} + bool Provider::evm_revert(std::string_view snapshotId) { nlohmann::json params = nlohmann::json::array(); params.push_back(snapshotId);