Neo N3 Rust Development Pack
A complete Rust SDK for Neo N3 smart contract development, providing a well-designed syntax and comprehensive functionality for building production-ready smart contracts.
🚀 Features
- Complete Neo N3 Type System: Full support for all Neo N3 data types
- System Call Integration: Direct access to all Neo N3 system calls
- Storage Operations: Comprehensive storage management with type safety
- Event System: Built-in event emission and handling
- Macro System: Powerful procedural macros for contract development
- Runtime Integration: Complete runtime environment for smart contracts
- Testing Framework: Built-in testing and benchmarking support
Compatibility Note
The devpack binary codec now uses postcard for maintained serde-based
serialization. Serialized bytes produced by older repository revisions that used
bincode are not guaranteed to round-trip with the current
neo_devpack::codec helpers, so persisted contract data should be versioned or
migrated explicitly when upgrading.
📦 Installation
Add to your Cargo.toml:
[]
= "0.5.8"
🎯 Quick Start
Basic Contract
use *;
Token Contract
use *;
🏗️ Architecture
Core Components
- neo-types: Core Neo N3 data types and structures
- neo-syscalls: System call bindings and wrappers
- neo-runtime: Runtime environment and utilities
- neo-macros: Procedural macros for contract development
Type System
// Primitive types
let int_value = new;
let bool_value = new;
let string_value = from_str;
let byte_string = from_slice;
// Collection types
let mut array = new;
array.push;
let mut map = new;
map.insert;
// Complex types
let mut struct_data = new;
struct_data.set_field;
Storage Operations
System Calls
// Runtime operations
let timestamp = get_time?;
let gas_left = get_gas_left?;
let caller = get_calling_script_hash?;
// Storage operations
let context = get_storage_context?;
let value = get?;
put?;
// Crypto operations
let hash = sha256?;
let signature_valid = verify_signature?;
Events
// Emit event
let event = TransferEvent ;
event.emit?;
To describe manifest metadata (events, permissions, supported standards, trusts, etc.) use the supplied macros instead of maintaining JSON by hand:
use *;
neo_permission!;
neo_supported_standards!;
neo_trusts!;
Each invocation emits a neo.manifest custom section that wasm-neovm merges during translation, keeping your NEF manifest aligned with the code without extra tooling.
🧪 Testing
Unit Tests
Integration Tests
use ;
use ;
neo-test also supports deployment/update lifecycle checks (deploy, update,
update_with_manifest, destroy) and context-aware storage assertions for
writable vs read-only contexts.
Use #[neo_test] when you want a host #[test] wrapper generated around a
helper function:
Run the test suites with:
Benchmarks
🔧 Configuration
Contract Manifest
Storage Configuration
📚 Examples
Hello World Contract
- Basic contract structure
- Method definitions
- Entry points
Token Contract
- ERC-20 like functionality
- Transfer operations
- Balance management
- Approval system
Storage Contract
- Data persistence
- User management
- Settings and counters
- Data serialization
🚀 Deployment
Build Configuration
[]
= "my-neo-contract"
= "0.1.0"
= "2021"
[]
= "0.5.8"
[[]]
= "contract"
= "src/main.rs"
Target Configuration
🔍 Debugging
Debug Information
Error Handling
📖 API Reference
Core Types
NeoInteger: 32-bit integer typeNeoBoolean: Boolean typeNeoByteString: Byte array typeNeoString: String typeNeoArray<T>: Dynamic array typeNeoMap<K, V>: Key-value map typeNeoStruct: Structure typeNeoValue: Union type for all Neo types
Runtime Operations
NeoRuntime: Runtime environment operationsNeoStorage: Storage operationsNeoCrypto: Cryptographic operationsNeoJSON: JSON serialization/deserialization
Macros
#[neo_contract]: Contract definition#[neo_method]: Method definition#[neo_event]: Event definition#[neo_storage]: Storage definition#[neo_entry]: Entry point definition
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🆘 Support
- Documentation: docs.rs/neo-devpack
- Issues: GitHub Issues
- Discussions: GitHub Discussions
🎉 Acknowledgments
- Neo N3 Development Team
- Rust Community
- LLVM Project
- All contributors and supporters