Expand description
Neo N3 Utilities Module
Provides Neo N3 blockchain-specific utilities for NEF (Neo Executable Format) generation and method tokens.
§Key Components
MethodToken- Cross-contract call optimization tokensbuild_nef_with_tokens- NEF file generation with method tokensclamp_nef_source_with_flag- Source code embedding in NEF
§NEF Format
The Neo Executable Format (NEF) is the standard container for Neo N3 smart contracts, containing bytecode, metadata, and optional method tokens.
Structs§
- Method
Token - Method token for cross-contract calls in NEF format.
- Parsed
Nef - Result of parsing a NEF file via
parse_nef.
Constants§
- MAX_
CALL_ FLAGS - Bitmask of valid CallFlags values (
CallFlags.All). Used to validate call flags in method tokens. - MAX_
METHOD_ TOKENS - Maximum number of method tokens allowed in a single NEF file. Method tokens enable optimized cross-contract calls. The NEF3 spec permits up to 512 entries; real-world contracts compiled by Neo.Compiler.CSharp / Neow3j can exceed 128.
- MAX_
SCRIPT_ SIZE - Maximum script size in NEF (512 KB)
- MAX_
TOKEN_ METHOD_ LENGTH - Maximum byte length of a method name stored in a NEF method token. Method names exceeding this limit will be truncated.
- NEF_
HEADER_ SIZE - NEF header size in bytes
- NEF_
MAGIC - NEF file magic bytes (“NEF3”)
- NEF_
SOURCE_ MAX_ BYTES - Publicly exposed maximum byte length for the NEF
sourcefield.
Functions§
- build_
nef - Build a NEF (Neo Executable Format) file from raw NeoVM bytecode.
- build_
nef_ with_ tokens - Build a NEF file with method tokens for cross-contract calls.
- clamp_
nef_ source - Clamp a NEF source string to the maximum allowed byte length, preserving UTF-8 boundaries.
- clamp_
nef_ source_ with_ flag - Clamp a NEF source string and report whether truncation occurred.
- compute_
contract_ hash - Compute the Neo N3 contract hash for a deployment transaction.
- format_
uint160_ hex_ be - Format a Neo UInt160 (little-endian bytes) as a 0x-prefixed big-endian hex string.
- parse_
nef - Parse a Neo N3 NEF3 file produced by
build_nef_with_tokens. - parse_
uint160_ hex_ be - Parse a Neo UInt160 from a 0x-prefixed (or raw) big-endian hex string.