neo3/neo_builder/
mod.rs

1//! # Neo Builder Module (v0.1.8)
2//!
3//! Advanced tooling for constructing Neo N3 transactions and smart contract scripts.
4//!
5//! ## Overview
6//!
7//! The neo_builder module provides a comprehensive set of utilities for constructing
8//! and manipulating Neo N3 transactions and scripts. It offers a flexible API for
9//! building various types of transactions, from simple transfers to complex
10//! multi-signature contract invocations.
11//!
12//! ## Key Components
13//!
14//! ### Transaction Building
15//!
16//! - **Transaction Builder**: Fluent API for creating and configuring transactions
17//! - **Fee Calculation**: Automatic network and system fee calculation
18//! - **Signer Management**: Support for multiple transaction signers with different scopes
19//! - **Witness Configuration**: Tools for creating and managing transaction witnesses
20//! - **Attribute Handling**: Support for transaction attributes
21//!
22//! ### Script Construction
23//!
24//! - **Script Builder**: Create VM scripts for contract invocation
25//! - **Opcode Support**: Full support for Neo VM opcodes
26//! - **Parameter Handling**: Type-safe handling of contract parameters
27//! - **Verification Scripts**: Utilities for building signature verification scripts
28//!
29//! ### Advanced Features
30//!
31//! - **Multi-signature Support**: Create and work with multi-signature accounts
32//! - **Helper Methods**: Convenience methods for common operations
33//! - **Serialization**: Serialization utilities for network transmission
34//!
35//! ## Examples
36//!
37//! ### Building Transactions and Scripts
38//!
39//! ```no_run
40//! use neo3::neo_builder::{ScriptBuilder, Signer, WitnessScope, TransactionSigner};
41//! use neo3::neo_types::{ContractParameter, ScriptHash};
42//! use std::str::FromStr;
43//!
44//! fn basic_examples() -> Result<(), Box<dyn std::error::Error>> {
45//!     // 1. Create a simple script builder
46//!     let mut script_builder = ScriptBuilder::new();
47//!     script_builder.push_data("Hello Neo!".as_bytes().to_vec());
48//!     let script = script_builder.to_bytes();
49//!     println!("Script length: {} bytes", script.len());
50//!     
51//!     // 2. Create a transaction signer
52//!     let script_hash = ScriptHash::from_str("0x1234567890123456789012345678901234567890")?;
53//!     let _signer = Signer::TransactionSigner(
54//!         TransactionSigner::new(script_hash, vec![WitnessScope::CalledByEntry])
55//!     );
56//!     
57//!     // 3. Example contract call
58//!     let mut contract_builder = ScriptBuilder::new();
59//!     let gas_token = ScriptHash::from_str("d2a4cff31913016155e38e474a2c06d08be276cf")?;
60//!     contract_builder.contract_call(
61//!         &gas_token,
62//!         "balanceOf",
63//!         &[ContractParameter::h160(&script_hash)],
64//!         None,
65//!     )?;
66//!     let contract_script = contract_builder.to_bytes();
67//!     println!("Contract script length: {} bytes", contract_script.len());
68//!     
69//!     Ok(())
70//! }
71//! ```
72
73pub use error::*;
74pub use script::*;
75pub use transaction::*;
76pub use utils::*;
77
78mod error;
79mod script;
80mod transaction;
81mod utils;
82
83pub fn add(left: usize, right: usize) -> usize {
84	left + right
85}
86
87#[cfg(test)]
88mod tests {
89	use super::*;
90
91	#[test]
92	fn it_works() {
93		let result = add(2, 2);
94		assert_eq!(result, 4);
95	}
96}