From d7bc36cd8e937a9f9f5e682bee113c620b549fac Mon Sep 17 00:00:00 2001 From: grw-ms Date: Thu, 7 Sep 2023 07:15:19 -0700 Subject: [PATCH] docs: add docs for `hardhat_setNonce` --- SUPPORTED_APIS.md | 35 ++++++++++++++++++++++++++++++++++- test_endpoints.http | 14 ++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/SUPPORTED_APIS.md b/SUPPORTED_APIS.md index c3bec4c3..1969a403 100644 --- a/SUPPORTED_APIS.md +++ b/SUPPORTED_APIS.md @@ -102,7 +102,7 @@ The `status` options are: | `HARDHAT` | `hardhat_setMinGasPrice` | `NOT IMPLEMENTED` | Sets the minimum gas price | | `HARDHAT` | `hardhat_setNextBlockBaseFeePerGas` | `NOT IMPLEMENTED` | Sets the base fee per gas for the next block | | `HARDHAT` | `hardhat_setPrevRandao` | `NOT IMPLEMENTED` | Sets the PREVRANDAO value of the next block | -| `HARDHAT` | `hardhat_setNonce` | `NOT IMPLEMENTED`
[GitHub Issue #77](https://github.com/matter-labs/era-test-node/issues/77) | Sets the nonce of a given account | +| [`HARDHAT`](#hardhat-namespace) | [`hardhat_setNonce`](#hardhat_setnonce) | `SUPPORTED` | Sets the nonce of a given account | | `HARDHAT` | `hardhat_setStorageAt` | `NOT IMPLEMENTED` | Sets the storage value at a given key for a given account | | `HARDHAT` | `hardhat_stopImpersonatingAccount` | `NOT IMPLEMENTED`
[GitHub Issue #74](https://github.com/matter-labs/era-test-node/issues/74) | Stop impersonating an account after having previously used `hardhat_impersonateAccount` | | [`NETWORK`](#network-namespace) | [`net_version`](#net_version) | `SUPPORTED` | Returns the current network id
_(default is `260`)_ | @@ -717,6 +717,39 @@ curl --request POST \ }' ``` +### `hardhat_setNonce` + +[source](src/hardhat.rs) + +Modifies an account's nonce by overwriting it. +The new nonce must be greater than the existing nonce. + +#### Arguments + ++ `address: Address` - The `Address` whose nonce is to be changed ++ `nonce: U256` - The new nonce + +#### Status + +`SUPPORTED` + +#### Example + +```bash +curl --request POST \ + --url http://localhost:8011/ \ + --header 'content-type: application/json' \ + --data '{ + "jsonrpc": "2.0", + "id": "1", + "method": "hardhat_setNonce", + "params": [ + "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", + "0x1337" + ] + }' +``` + ## `ZKS NAMESPACE` ### `zks_estimateFee` diff --git a/test_endpoints.http b/test_endpoints.http index 2d2572dc..584afa46 100644 --- a/test_endpoints.http +++ b/test_endpoints.http @@ -279,6 +279,20 @@ content-type: application/json POST http://localhost:8011 content-type: application/json +{ + "jsonrpc": "2.0", + "id": "2", + "method": "hardhat_setNonce", + "params": [ + "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", + "0x56" + ] +} + +### +POST http://localhost:8011 +content-type: application/json + { "jsonrpc": "2.0", "id": "1",