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.
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.
- MAX_
SCRIPT_ SIZE - Maximum script size in NEF (512 KB)
- MAX_
SOURCE_ πLENGTH - Maximum byte length for the NEF
sourcefield (URL or identifier). - 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.
- calculate_
checksum π - 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.
- clamp_
utf8 π - compute_
contract_ hash - Compute the Neo N3 contract hash for a deployment transaction.
- emit_
push_ πbytes - emit_
push_ πu32 - format_
uint160_ hex_ be - Format a Neo UInt160 (little-endian bytes) as a 0x-prefixed big-endian hex string.
- hash160 π
- parse_
uint160_ hex_ be - Parse a Neo UInt160 from a 0x-prefixed (or raw) big-endian hex string.
- write_
fixed_ πstring - write_
varbytes π - write_
varint π - write_
varstring π