Skip to content

Using the Compiler

Using the Commandline Compiler

One of the build targets of the Neo DevPack for Solidity repository is neo-solc, the commandline compiler. Using neo-solc --help provides you with an explanation of all options. The compiler can produce various outputs, ranging from simple binaries and JSON manifests over assembly to standard JSON configurations.

Command Syntax

bash
neo-solc <source...> [options]

The compiler accepts one or more Solidity source files and produces Neo N3 deployment artifacts (.nef + .manifest.json). Standard JSON mode uses the Solidity-compatible JSON interface and can read from stdin or from --input.

bash
# Single file
neo-solc MyContract.sol -o build/

# Multiple files
neo-solc contracts/*.sol -o build/

# With devpack imports
neo-solc MyToken.sol -I devpack -o build/

# Standard JSON from a file
neo-solc --standard-json --input input.json --output output.json

Complete Flag Summary

FlagShortArgumentDefaultDescription
<source...>positionalrequiredInput Solidity file(s); omitted when --standard-json is used
--standard-jsonEnable Solidity Standard JSON input/output mode
--inputFILEstdinStandard JSON input file; requires --standard-json
--output-oFILEsource stemOutput prefix for single-file mode; directory/prefix handling for multi-file mode; JSON output file for Standard JSON
--optimize-OLEVEL2Optimization level (0-3)
--format-fFORMATcompleteOutput format: nef, manifest, complete, assembly, or json
--include-path-IDIRImport search path (repeatable)
--contractNAMEEmit only named contract (repeatable)
--verbose-vEnable verbose output
--calltEmit CALLT + method tokens for native calls
--analyzePrint a JSON upgrade/readiness analysis instead of compiling artifacts
--nef-sourceSTRINGOverride the source string embedded in generated NEF metadata
--deployerHASH160Deployer account hash used for deterministic contract hash calculation
--json-errorsEmit diagnostics as JSON errors
--json-warningsEmit diagnostics as JSON warnings
--WnoCODEDisable a warning code (repeatable)
--WerrorCODETreat a warning code as an error (repeatable)
--deny-wildcard-permissionsFail if manifest needs full wildcard permission
--deny-wildcard-contractsFail if manifest needs wildcard contract permission
--deny-wildcard-methodsFail if manifest needs wildcard method permission
--manifest-permissionsFILEJSON file with manifest permissions
--manifest-permissions-modeMODEmergeHow to apply permission overrides: merge or replace-wildcards

Base Path and Include Paths

The compiler resolves import directives by looking into the current directory and any directories provided via --include-path (or -I).

bash
neo-solc contract.sol -I devpack -I ./lib -o build/

Setting the EVM Version to Target

💡 NeoVM Difference

Neo DevPack for Solidity targets Neo N3 (NeoVM) exclusively. Standard EVM version targets (like istanbul, paris, cancun) do not apply and are safely ignored by the compiler if provided through standard JSON configurations.

Because Neo N3 relies on standard execution mechanics and syscall interfaces, versioning is primarily handled at the node runtime level rather than requiring specific hardfork flags during compilation.

Compiler Input and Output JSON Description

These JSON formats are used by the compiler API as well as the standard JSON interface of the commandline compiler. These interfaces are recommended for any programmatic interactions (like IDEs and framework toolchains).

To use the standard JSON interface from the command line, run:

bash
neo-solc --standard-json --input input.json > output.json

Input JSON Description

The input JSON format is completely compatible with the Ethereum Solidity Standard JSON format.

json
{
  "language": "Solidity",
  "sources": {
    "MyContract.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n..."
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "level": 2
    },
    "outputSelection": {
      "*": {
        "*": ["abi", "nef", "manifest"]
      }
    }
  }
}

Output JSON Description

The output JSON includes any compiler diagnostics (errors/warnings) and the compiled artifacts.

💡 NeoVM Difference

In EVM output, contracts produce evm.bytecode and abi fields. In Neo DevPack for Solidity, the output produces a Base64-encoded nef string and the structural Neo manifest.

json
{
  "contracts": {
    "MyContract.sol": {
      "MyContract": {
        "abi": { 
            "methods": [ ... ],
            "events": [ ... ]
        },
        "nef": "<base64-encoded NEF>",
        "manifest": { ... }
      }
    }
  },
  "errors": [
    {
      "component": "neo-devpack-solidity",
      "severity": "warning",
      "code": "COMPILER_WARNING",
      "message": "...",
      "formattedMessage": "...",
      "location": { "file": "MyContract.sol", "line": 10, "column": 1 }
    }
  ]
}

MIT Licensed