decred.org/dcrdex@v1.0.5/client/asset/eth/cmd/getgas/README.md (about)

     1  ## Gas Estimator Utility
     2  
     3  `getgas` is a program for getting gas estimates for DEX-critical operations
     4  on Ethereum. Use `getgas` to generate gas tables (`dexeth.Gases`) when adding a
     5  new token or a new contract version.
     6  
     7  If this is a new asset, you must populate either `dexeth.VersionedGases` or
     8  `dexeth.Tokens` with generous estimates before running `getgas`.
     9  
    10  ### Use
    11  - Create a credentials file. `getgas` will look for `~/dextest/credentials.json`.
    12  You can override that location with the `--creds` CLI argument.
    13  The credentials file should have the JSON format in the example below. The seed can be anything.
    14  
    15  **example credentials file**
    16  ```
    17  {
    18      "seed": "<32-bytes hex>",
    19      "providers": {
    20          "eth": {
    21              "testnet: [
    22                  "https://sepolia.infura.io/v3/<API key>"
    23              ],
    24              "mainnet": [
    25                  "https://mainnet.infura.io/v3/<API key>"
    26              ]
    27          },
    28          "polygon": { ... }
    29      }
    30  }
    31  ```
    32  - Select the blockchain with `--chain`. The default is `--chain eth`, but `--chain polygon` can be selected as well.
    33  
    34  - Use the `--readcreds` utility to check the validity of the credentials file and to print the address. e.g. `./getgas --readcreds --mainnet`. 
    35  
    36  - Decide the maximum number of swaps you want in the largest initiation transaction, `--n`. Minimum is 2. `getgas` will check initiations with from 1 up to `n` swaps. There is a balance between cost and precision. Using more than 2 generates an average over `n - 1` intiations to calculate the cost of additional swaps (`Gases.SwapAdd`) and redeems (`Gases.RedeemAdd`).
    37  
    38  - Use the `--fundingrequired` utility to see what funding is required for the estimate wallet. e.g. `./getgas --fundingrequired --n 3 --token usdc.eth --testnet`.
    39  
    40  - If you run `getgas` with insufficient or zero ETH and/or token balance on the seed, no transactions will be sent and you'll get a message indicating the amount of funding needed to run.
    41  
    42  - A network **MUST** be specified with the `--mainnet`, `--testnet`, or `--simnet` flag.
    43  
    44  - You can return Ethereum from the estimate wallet to a specified address with the `--return` utility, e.g. `./getgas --return d12ab7cf72ccf1f3882ec99ddc53cd415635c3be --mainnet`
    45  
    46  -- **DO NOT** send any more token balance that what is suggested by the `--fundingrequired`. Remaining token balance is not returned.
    47  
    48  - Use `--help` to see additional options.
    49  
    50  - **If running on mainnet, real funds will be used** for fees based on the current network base fee and tip rate. All swaps sent are just 1 gwei (atom), with fees additional. If testing a token, 1 atom will be transferred to a [random address](https://ethereum.stackexchange.com/a/3298/83118) and will be unrecoverable.
    51  
    52  **example usage**
    53  ```
    54  go build -tags lgpl
    55  ./getgas --simnet --n 3 --token usdc.eth
    56  ```