1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
// Clippy suppressions — each kept intentionally:
// RPC error enums carry provider-specific payloads; boxing adds indirection with no consumer benefit
// Builder-pattern constructors mirror the Neo N3 protocol fields 1:1
// `into_*` / `to_*` naming follows Neo C# SDK conventions for cross-language parity
// Re-export modules share parent name by design (e.g. neo_types::neo_types)
// Nested generics in RPC futures are unavoidable without boxing
// Feature flags checked at build time by downstream crates
//! 
//! # NeoRust SDK v1.0.6
//!
//! A production-ready Rust SDK for the Neo N3 blockchain with enterprise-grade features.
//!
//! [](https://crates.io/crates/neo3)
//! [](https://docs.rs/neo3)
//! [](https://opensource.org/licenses/MIT)
//!
//! ## Features
//!
//! This crate provides several feature flags to customize functionality:
//!
//! - **futures**: Enables async/futures support for asynchronous blockchain operations. This is recommended
//! for most applications that need to interact with the Neo blockchain without blocking.
//!
//! - **ledger**: Enables hardware wallet support via Ledger devices. When enabled, you can use Ledger
//! hardware wallets for transaction signing and key management. This feature provides an additional
//! security layer by keeping private keys on dedicated hardware.
//!
//! - **aws**: ⚠️ **DISABLED in v1.0.1** due to security vulnerabilities in rusoto dependencies.
//! Will be re-enabled in a future 1.x release with the modern AWS SDK. For AWS KMS integration,
//! use the legacy v0.3.x line or wait for updated AWS SDK support.
//!
//! - **sgx**: Enables Intel SGX (Software Guard Extensions) support for running Neo operations
//! in secure enclaves. This feature enables `no_std` compilation and provides hardware-based
//! security for sensitive operations like key management and transaction signing.
//!
//! - **no_std**: Enables `no_std` compilation for embedded systems and SGX environments.
//! This feature removes dependencies on the standard library, allowing the SDK to run in
//! constrained environments with custom allocators.
//!
//! To enable specific features in your project, modify your `Cargo.toml` as follows:
//!
//! ```toml
//! [dependencies]
//! neo3 = { version = "1.0.6", features = ["futures", "ledger"] }
//! ```
//!
//! You can disable default features with:
//!
//! ```toml
//! neo3 = { version = "1.0.6", default-features = false, features = ["futures"] }
//! ```
//!
//! ## Overview
//!
//! NeoRust is a complete SDK designed to make Neo N3 blockchain development in Rust
//! intuitive, type-safe, and productive. The library provides full support for all
//! Neo N3 features and follows Rust best practices for reliability and performance.
//!
//! ### New in v1.0.x
//! - **WebSocket Support**: Real-time blockchain events with automatic reconnection
//! - **HD Wallets (BIP-39/44)**: Deterministic wallet generation and derivation
//! - **Transaction Simulation**: Preview fees, VM state, and state changes before sending
//! - **High-Level SDK API**: Simplified entrypoint (`Neo`) for common operations
//! - **Enhanced Error Handling**: Consistent `NeoError` with recovery suggestions
//!
//! ## Core Modules
//!
//! NeoRust is organized into specialized modules, each handling specific aspects of Neo N3:
//!
//! - [**neo_builder**](neo_builder): Transaction construction and script building
//! - [**neo_clients**](neo_clients): Neo node interaction and RPC client implementations
//! - [**neo_codec**](neo_codec): Serialization and deserialization of Neo data structures
//! - [**neo_config**](neo_config): Configuration for networks and client settings
//! - [**neo_contract**](neo_contract): Smart contract interaction and token standards
//! - [**neo_crypto**](neo_crypto): Cryptographic primitives and operations
//! - [**neo_error**](neo_error): Unified error handling
//! - [**neo_fs**](neo_fs): NeoFS distributed storage system integration
//! - [**neo_protocol**](neo_protocol): Core blockchain protocol implementations
//! - [**neo_types**](neo_types): Core data types and primitives for Neo N3
//! - [**neo_utils**](neo_utils): General utility functions
//! - [**neo_wallets**](neo_wallets): Wallet management for Neo N3
//! - [**neo_x**](neo_x): Neo X EVM compatibility layer
//!
//! ## Quick Start
//!
//! Import all essential types and traits using the `prelude`:
//!
//! ```rust
//! use neo3::prelude::*;
//! ```
//!
//! ## Complete Example
//!
//! Here's a comprehensive example showcasing common operations with the NeoRust SDK:
//!
//! ```no_run
//! use neo3::neo_protocol::{Account, AccountTrait};
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//!
//! async fn neo_example() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to Neo TestNet
//! let provider = HttpProvider::new("https://testnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // Get basic blockchain information
//! let block_height = client.get_block_count().await?;
//! println!("Connected to Neo TestNet at height: {}", block_height);
//!
//! // Create a new wallet account
//! let account = Account::create()?;
//! println!("New account created:");
//! println!(" Address: {}", account.get_address());
//! println!(" Script Hash: {}", account.get_script_hash());
//!
//! // Get version information
//! let version = client.get_version().await?;
//! println!("Node version: {}", version.user_agent);
//!
//! Ok(())
//! }
//! ```
//!
//! ## Usage Examples
//!
//! ### Connecting to a Neo N3 node
//!
//! ```no_run
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to Neo N3 MainNet
//! let provider = HttpProvider::new("https://mainnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // Get basic blockchain information
//! let block_count = client.get_block_count().await?;
//! println!("Current block count: {}", block_count);
//!
//! let version = client.get_version().await?;
//! println!("Node version: {}", version.user_agent);
//!
//! Ok(())
//! }
//! ```
//!
//! ### Creating and sending a transaction
//!
//! ```no_run
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//! use neo3::neo_protocol::{Account, AccountTrait};
//! use neo3::neo_types::{ScriptHash, ContractParameter, ScriptHashExtension};
//! use neo3::neo_builder::{ScriptBuilder, TransactionBuilder, AccountSigner};
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Initialize the JSON-RPC provider
//! let provider = HttpProvider::new("https://testnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // Create accounts for the sender and recipient
//! // Load sender key from an environment variable to avoid hardcoding secrets.
//! let sender_wif = std::env::var("NEO_WIF")?;
//! let sender = Account::from_wif(&sender_wif)?;
//! let recipient = ScriptHash::from_address("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")?;
//!
//! // Get the GAS token contract
//! let gas_token_hash = ScriptHash::from_str("d2a4cff31913016155e38e474a2c06d08be276cf")?;
//!
//! // Build the transaction using the ScriptBuilder
//! let script = ScriptBuilder::new()
//! .contract_call(
//! &gas_token_hash,
//! "transfer",
//! &[
//! ContractParameter::h160(&sender.get_script_hash()),
//! ContractParameter::h160(&recipient),
//! ContractParameter::integer(1_0000_0000), // 1 GAS (8 decimals)
//! ContractParameter::any(),
//! ],
//! None,
//! )?
//! .to_bytes();
//!
//! // Create and configure the transaction
//! let mut tx_builder = TransactionBuilder::with_client(&client);
//! tx_builder
//! .set_script(Some(script))
//! .set_signers(vec![AccountSigner::called_by_entry(&sender)?.into()])?
//! .valid_until_block(client.get_block_count().await? + 5760)?; // Valid for ~1 day
//!
//! // Sign the transaction
//! let mut tx = tx_builder.sign().await?;
//!
//! // Send the transaction
//! let result = tx.send_tx().await?;
//! println!("Transaction sent: {}", result.hash);
//!
//! // Wait for the transaction to be confirmed
//! println!("Waiting for confirmation...");
//! tx.track_tx(10).await?;
//! println!("Transaction confirmed!");
//!
//! // Get the application log
//! let app_log = tx.get_application_log(&client).await?;
//! println!("Application log: {:?}", app_log);
//!
//! Ok(())
//! }
//! ```
//!
//! ### Interacting with a smart contract
//!
//! ```no_run
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//! use neo3::neo_types::ScriptHash;
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to Neo N3 TestNet
//! let provider = HttpProvider::new("https://testnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // Get the NEO token contract
//! let neo_token = ScriptHash::from_str("ef4073a0f2b305a38ec4050e4d3d28bc40ea63f5")?;
//!
//! // Call a read-only method (doesn't require signing)
//! let result = client
//! .invoke_function(&neo_token, "symbol".to_string(), vec![], None)
//! .await?;
//!
//! // Parse the result
//! if let Some(item) = result.stack.first() {
//! println!("NEO Token Symbol: {:?}", item);
//! }
//!
//! // Get the total supply
//! let supply_result = client
//! .invoke_function(&neo_token, "totalSupply".to_string(), vec![], None)
//! .await?;
//!
//! println!("Total Supply Result: {:?}", supply_result);
//!
//! Ok(())
//! }
//! ```
//!
//! ### Working with NEP-17 tokens
//!
//! ```no_run
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//! use neo3::neo_protocol::{Account, AccountTrait};
//! use neo3::neo_types::{ScriptHash, ContractParameter};
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to Neo N3 TestNet
//! let provider = HttpProvider::new("https://testnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // Create an account from WIF (Wallet Import Format)
//! let wif = std::env::var("NEO_WIF")?;
//! let account = Account::from_wif(&wif)?;
//!
//! // Get account information
//! println!("Account address: {}", account.get_address());
//! println!("Account script hash: {}", account.get_script_hash());
//!
//! // Get GAS token balance for the account
//! let gas_token = ScriptHash::from_str("d2a4cff31913016155e38e474a2c06d08be276cf")?;
//!
//! let balance_result = client
//! .invoke_function(
//! &gas_token,
//! "balanceOf".to_string(),
//! vec![ContractParameter::h160(&account.get_script_hash())],
//! None,
//! )
//! .await?;
//!
//! // Parse the balance result
//! if let Some(item) = balance_result.stack.first() {
//! println!("GAS Balance: {:?}", item);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ### Using the Neo Name Service (NNS)
//!
//! ```no_run
//! use neo3::neo_clients::{HttpProvider, RpcClient, APITrait};
//! use neo3::neo_types::{ContractParameter, ScriptHash};
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Connect to Neo N3 TestNet
//! let provider = HttpProvider::new("https://testnet1.neo.org:443")?;
//! let client = RpcClient::new(provider);
//!
//! // NNS contract on TestNet (use MainNet hash for production)
//! let nns_contract = ScriptHash::from_str("50ac1c37690cc2cfc594472833cf57505d5f46de")?;
//!
//! // Check if a name is available
//! let available_result = client
//! .invoke_function(
//! &nns_contract,
//! "isAvailable".to_string(),
//! vec![ContractParameter::string("myname.neo".to_string())],
//! None,
//! )
//! .await?;
//!
//! if let Some(item) = available_result.stack.first() {
//! println!("Is 'myname.neo' available: {:?}", item);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! For more usage examples, refer to the [`examples` directory](https://github.com/R3E-Network/NeoRust/tree/master/examples) in the repository.
//!
//! ## Project Structure
//!
//! ```text
//! NeoRust
//! ├── examples
//! │ ├── neo_nodes - Examples for connecting to Neo nodes
//! │ ├── neo_transactions - Examples for creating and sending transactions
//! │ ├── neo_smart_contracts - Examples for interacting with smart contracts
//! │ ├── neo_wallets - Examples for wallet management
//! │ ├── neo_nep17_tokens - Examples for working with NEP-17 tokens
//! │ └── neo_nns - Examples for using the Neo Name Service
//! └── src
//! ├── neo_builder - Transaction and script building utilities
//! ├── neo_clients - Neo node interaction clients (RPC and WebSocket)
//! ├── neo_codec - Encoding and decoding for Neo-specific data structures
//! ├── neo_config - Network and client configuration management
//! ├── neo_contract - Smart contract interaction abstractions
//! ├── neo_crypto - Neo-specific cryptographic operations
//! ├── neo_protocol - Neo network protocol implementation
//! ├── neo_sgx - SGX support for secure enclave execution
//! ├── neo_types - Core Neo ecosystem data types
//! └── neo_wallets - Neo asset and account management
//! ```
//!
//! ## Module Overview
//!
//! - **neo_builder**: Transaction and script building utilities.
//! - Transaction construction and signing
//! - Script building for contract calls
//! - Network fee calculation
//!
//! - **neo_clients**: Neo node interaction clients.
//! - HTTP, WebSocket, and IPC providers
//! - JSON-RPC client implementation
//! - Event subscription and notification handling
//!
//! - **neo_codec**: Encoding and decoding for Neo-specific data structures.
//! - Binary serialization and deserialization
//! - Neo VM script encoding
//!
//! - **neo_config**: Network and client configuration management.
//! - Network magic numbers
//! - Client settings
//!
//! - **neo_contract**: Smart contract interaction abstractions.
//! - Contract invocation and deployment
//! - NEP-17 token standard implementation
//! - Native contracts (GAS, NEO, etc.)
//! - Neo Name Service (NNS) support
//!
//! - **neo_crypto**: Neo-specific cryptographic operations.
//! - Key generation and management
//! - Signing and verification
//! - Hashing functions
//!
//! - **neo_protocol**: Neo network protocol implementation.
//! - Account management
//! - Address formats and conversions
//!
//! - **neo_types**: Core Neo ecosystem data types.
//! - Script hashes
//! - Contract parameters
//! - Block and transaction types
//! - NNS name types
//!
//! - **neo_wallets**: Neo asset and account management.
//! - Wallet creation and management
//! - NEP-6 wallet standard support
//! - Account import/export
//! - Wallet backup and recovery
//!
//! For detailed information, consult the documentation of each module.
// Production-ready Neo N3 SDK - warnings are treated as errors in CI
// SGX support (only when building for the SGX target)
extern crate sgx_tstd as std;
// Required for no_std when targeting SGX
extern crate alloc;
// For macro expansions only, not public API.
extern crate self as neo3;
/// Current version of the `neo3` crate.
pub const VERSION: &str = env!;
// Core modules - always available
// All modules unconditionally available
// High-level SDK API (new in v1.0.x)
// Re-exports for convenience
pub use neo_builder as builder;
pub use neo_clients as providers;
pub use neo_codec as codec;
pub use neo_config as config;
pub use neo_crypto as crypto;
pub use neo_protocol as protocol;
pub use neo_wallets as wallets;
pub use neo_x as x;
// No need to re-export specialized modules as they're already public with their full names
// Re-export common types directly in lib.rs for easy access
pub use crate;
// Add direct re-exports for commonly used serde utils
pub use crate;
// Re-export additional contract types
pub use crate;
// Re-export value extension trait
pub use crateValueExtension;
/// Convenient imports for commonly used types and traits.
///
/// This prelude module provides a single import to access the most commonly used
/// components of the NeoRust SDK. Import it with:
///
/// ```rust
/// use neo3::prelude::*;
/// ```
// Adding trait implementations for serde JSON serialization
// These extensions will be used by the http-client feature
// Explicitly mark external dependencies with cfg_attr for docs.rs
pub use futures;
pub use coins_ledger;
// AWS feature is disabled in v1.0.1 due to security vulnerabilities
// #[cfg(feature = "aws")]
// #[cfg_attr(docsrs, doc(cfg(feature = "aws")))]
// pub use rusoto_core;
//
// #[cfg(feature = "aws")]
// #[cfg_attr(docsrs, doc(cfg(feature = "aws")))]
// pub use rusoto_kms;