Analysing the Compiler Output
When you compile a Solidity contract using neo-solc, the output differs significantly from standard solc.
💡 NeoVM Difference
Standard Solidity outputs an EVM binary (often represented as a hex string) and an Ethereum ABI JSON. Neo DevPack for Solidity outputs a .nef (Neo Executable Format) binary file and a .manifest.json file.
The NEF File (.nef)
The NEF file is the compiled bytecode executable deployed to the Neo blockchain. It is a strictly formatted binary file containing:
- Magic Header: Identifies the file as a Neo N3 executable (
0x3346454E). - Compiler Name: A 64-byte string identifying the compiler (for example,
neo-devpack-solidity-0.18.0). - Source/Version Context: Metadata tracking the compiler version used.
- Method Tokens: A table mapping external contract calls to optimize runtime execution (if
--calltis used). - Script: The actual NeoVM opcodes representing your contract logic.
- Checksum: A SHA-256 checksum to ensure file integrity.
You can disassemble the NEF file during compilation by passing the -f assembly flag:
bash
neo-solc MyContract.sol -O2 -f assembly -o build/MyContractThe Manifest File (.manifest.json)
The manifest file is a comprehensive JSON document describing how the Neo blockchain and other contracts can interact with your executable.
Key sections include:
abi: Describes the methods and events the contract exposes.methods: Arrays of functions, their parameters (using Neo types likeHash160,Integer), andsafeflags (equivalent toview/pure).events: Notifications the contract emits.
permissions: Defines which external contracts and methods this contract is allowed to call. This is critical for security.supportedstandards: Lists the NEP standards the contract implements (e.g.,NEP-17,NEP-11), which are automatically inferred by the compiler.trusts: Specifies which contracts are allowed to invoke this contract without user warnings.extra: Custom metadata like author, email, or description.
Manifest Example
json
{
"name": "MyToken",
"groups": [],
"features": {},
"supportedstandards": ["NEP-17"],
"abi": {
"methods": [
{
"name": "balanceOf",
"parameters": [{ "name": "account", "type": "Hash160" }],
"returntype": "Integer",
"offset": 45,
"safe": true
}
],
"events": []
},
"permissions": [
{
"contract": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
"methods": ["transfer"]
}
]
}