π‘οΈ Safety & Pre-Execution Checks
π 1. Confirmation Gate
Before calling any write function (deploy(), transfer(), mint(), etc.), Dialect AI:
Displays a summary of the action:
Contract type
Parameters (e.g., token name, supply)
Recipient address
Estimated gas cost
Prompts the user:
βDo you want to proceed with this transaction?β
Waits for explicit confirmation (via frontend UI or chat message)
π§ Example:
βYou're about to send 200 MYT to
0xabc.... Estimated gas: 0.002 ETH. Please confirm to proceed.β
π 2. Wallet Availability Check
Verifies that the user has a connected wallet
Retrieves their address, signer, and chain ID
Fails gracefully if wallet is missing or disconnected
If the user is not connected:
β βNo wallet detected. Please connect MetaMask to continue.β
β½ 3. Gas Estimation
Dialect AI automatically performs a dry-run gas estimation using:
This allows the bot to:
Predict the cost of the transaction in gas units
Convert to ETH using
provider.getGasPrice()Warn the user if the cost exceeds a threshold (e.g., gas spike)
π§ Example:
βThis transaction will likely cost ~0.0013 ETH in gas. Proceed?β
π§ͺ 4. Dry Run / Static Call (If Possible)
Where supported, Dialect AI attempts to simulate the transaction without sending it to the network using callStatic:
Use cases:
Checking if a token transfer would revert (e.g., insufficient balance)
Verifying mint success before committing gas
Ensuring the deployer has enough ETH to cover deployment
Dry run failures result in:
β βThis transaction would fail: Revert - insufficient funds.β
π 5. Nonce & Duplicate Prevention
Dialect AI prevents double submissions by:
Tracking pending transactions in memory (
txPool)Locking intent execution until the previous transaction is confirmed or rejected
Warning the user about duplicate actions (e.g., sending the same token twice)
π§ Example:
βYou already have a pending transfer of 50 MYT to this address. Wait until it's confirmed before retrying.β
π¨ 6. Fallbacks for Failed Transactions
If a transaction fails:
The bot detects
revertreasons (e.g., gas limit exceeded, failed require)Parses the error via
try/catchfromethers.jsReturns a helpful explanation to the user
Example:
Last updated