Sei: Compile Contract icon

Sei: Compile Contract

Compile Solidity source code to bytecode and ABI

Sei: Compile Contract

AI-generated

Overview

This node compiles Solidity smart contract source code into Ethereum Virtual Machine (EVM) bytecode and ABI (Application Binary Interface). It supports compiling custom Solidity code or using predefined contract templates for common token standards like ERC-20 and ERC-721.

Typical use cases include:

  • Developers wanting to compile their Solidity contracts directly within an n8n workflow.
  • Quickly generating bytecode and ABI for deployment or further processing.
  • Using standard token contract templates to bootstrap token creation without writing Solidity from scratch.

For example, a user can input a Solidity contract source, specify the contract name and compiler version, enable optimization, and receive compiled bytecode and ABI as output. Alternatively, they can select an ERC-20 or ERC-721 template to compile a standard token contract.

Properties

Name Meaning
Solidity Source Code The Solidity source code to compile. Can be custom code or overridden by selected template.
Contract Name The specific contract name to compile if multiple contracts exist in the source code.
Compiler Version Solidity compiler version to use. Options: 0.8.19, 0.8.20, 0.8.21, 0.8.22, 0.8.23, 0.8.24
Enable Optimization Whether to enable compiler optimization (boolean).
Optimization Runs Number of optimization runs to perform (only shown if optimization enabled).
Include Templates Whether to load and use a predefined contract template instead of custom source code.
Template Type If templates are included, choose which one: "ERC-20 Token" or "ERC-721 NFT".

Output

The node outputs a JSON object with the following structure:

  • success (boolean): Indicates if compilation succeeded.
  • contractName (string): The name of the compiled contract.
  • bytecode (string): The compiled EVM bytecode prefixed with "0x".
  • abi (array): The contract's ABI describing its interface.
  • constructorAbi (object|null): ABI entry for the constructor function, if present.
  • metadata (object):
    • compilerVersion: The Solidity compiler version used.
    • optimization: Whether optimization was enabled.
    • optimizationRuns: Number of optimization runs.
    • sourceCode: Either "Template: " or "Custom" depending on source.
  • warnings (array): Any compiler warnings encountered.
  • errors (array, if any): Compilation errors if compilation failed.
  • timestamp (string): ISO timestamp of compilation.

If compilation fails, the output includes error messages and may list available contracts found in the source.

No binary data output is produced by this node.

Dependencies

  • Uses the Solidity compiler (solc) JavaScript package bundled with the node.
  • No external API keys or services are required.
  • No special environment variables needed.
  • The node internally supports Solidity versions 0.8.19 through 0.8.24.

Troubleshooting

  • Common issues:

    • Specifying a contract name not present in the source will cause an error indicating the contract was not found.
    • Syntax errors or invalid Solidity code will produce compiler errors.
    • Selecting a template type other than "ERC20" or "ERC721" when templates are enabled will throw an error.
  • Error messages:

    • "Contract '<name>' not found in compiled output": Check that the contract name matches exactly the contract defined in the source.
    • Compiler errors with formatted messages: Review Solidity code for syntax or semantic mistakes.
    • "Unknown template type: <type>": Use only supported template types ("ERC20", "ERC721").
  • Resolution tips:

    • Verify Solidity source code correctness before compiling.
    • Ensure the contract name matches the exact contract in the source.
    • Use supported compiler versions.
    • Enable optimization only if desired; adjust optimization runs accordingly.

Links and References

Discussion