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
๐ฆ Installation
Add to your Cargo.toml:
[]
= "0.1.0"
๐ฏ 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
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.1.0"
[[]]
= "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