πŸ›‘οΈ 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 revert reasons (e.g., gas limit exceeded, failed require)

  • Parses the error via try/catch from ethers.js

  • Returns a helpful explanation to the user

Example:

Last updated