🛠️ Compilation Workflow in Dialect AI

1. 🧾 Contract Source Generated

  • A full Solidity contract is created using injected user parameters into a pre-audited template.

  • Example:

solidityCopyEditpragma solidity ^0.8.19;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract EcoToken is ERC20 {
    constructor() ERC20("EcoToken", "ECO") {
        _mint(msg.sender, 5000000 * 10 ** decimals());
    }
}

2. 📦 Compiler Input Constructed

Dialect AI constructs a standardized solc-js input JSON:

jsonCopyEdit{
  "language": "Solidity",
  "sources": {
    "MyToken.sol": {
      "content": "pragma solidity ^0.8.19; import ..."
    }
  },
  "settings": {
    "outputSelection": {
      "*": {
        "*": ["abi", "evm.bytecode", "evm.deployedBytecode"]
      }
    }
  }
}
  • Ensures compatibility with specific Solidity versions

  • Isolates compiled output to only what's needed

  • Supports multi-file import resolution (planned via bundlers or @openzeppelin CDNs)


3. 🔍 Syntax Checking & Version Enforcement

Before compiling:

  • The bot ensures the Solidity version (pragma solidity ^0.8.19) is consistent with the one supported by solc-js

  • Syntax errors are caught pre-deployment

  • Errors and warnings from the compiler output are captured and reported back to the user

Example Errors Handled:

  • Typos in source (e.g., publick instead of public)

  • Outdated syntax (e.g., pre-0.8 style safe math)

  • Import failures or missing libraries

  • Unused variables or unreachable code (warning level)


4. 🏗️ Compilation Execution

Using the solc.compile(input) function, the contract is compiled:

  • The result includes the ABI, bytecode, deployedBytecode, and compiler metadata

  • The bot parses and extracts:

    • contract.abi for interaction

    • evm.bytecode.object for deployment


5. 📤 Output Handling

The compiled contract artifacts are used for:

  • Deployment via ethers.ContractFactory

  • UI previews of the contract interface (ABI visualization — coming soon)

  • Future versioning and audit logs

Sample output:

jsonCopyEdit{
  "abi": [...],
  "bytecode": "0x60806040...",
  "deployedBytecode": "0x6080604052..."
}

Last updated