neo3/neo_x/
mod.rs

1//! # Neo X
2//!
3//! Support for Neo X, an EVM-compatible chain maintained by Neo.
4//!
5//! ## Overview
6//!
7//! The neo_x module provides interfaces for interacting with Neo X, an EVM-compatible
8//! chain maintained by Neo. It includes:
9//!
10//! - EVM compatibility layer for interacting with Neo X as an Ethereum-compatible chain
11//! - Bridge functionality for transferring tokens between Neo N3 and Neo X
12//! - Transaction creation and signing for Neo X
13//! - Provider interfaces for connecting to Neo X nodes
14//!
15//! This module enables seamless integration between Neo N3 and EVM-compatible ecosystems,
16//! allowing developers to leverage both blockchain environments.
17//!
18//! ## Examples
19//!
20//! ### Connecting to Neo X and getting chain information
21//!
22//! ```ignore
23//! use neo3::neo_clients::{HttpProvider, RpcClient};
24//! use neo3::neo_x::NeoXProvider;
25//!
26//! #[tokio::main]
27//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
28//!     // Connect to Neo N3
29//!     let neo_provider = HttpProvider::new("https://mainnet1.neo.org:443")?;
30//!     let neo_client = RpcClient::new(neo_provider);
31//!     
32//!     // Initialize the Neo X EVM provider
33//!     let neo_x_provider = NeoXProvider::new("https://rpc.neo-x.org", Some(&neo_client));
34//!     
35//!     // Get the chain ID for Neo X
36//!     let chain_id = neo_x_provider.chain_id().await?;
37//!     println!("Neo X Chain ID: {}", chain_id);
38//!     
39//!     // Get the latest block number
40//!     let block_number = neo_x_provider.block_number().await?;
41//!     println!("Latest block number: {}", block_number);
42//!     
43//!     Ok(())
44//! }
45//! ```
46//!
47//! ### Using the bridge to transfer tokens between Neo N3 and Neo X
48//!
49//! ```ignore
50//! use neo3::neo_clients::{HttpProvider, RpcClient};
51//! use neo3::neo_protocol::Account;
52//! use std::str::FromStr;
53//!
54//! #[tokio::main]
55//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
56//!     // Connect to Neo N3
57//!     let neo_provider = HttpProvider::new("https://mainnet1.neo.org:443")?;
58//!     let neo_client = RpcClient::new(neo_provider);
59//!     
60//!     // Create an account
61//!     let account = Account::from_wif("YOUR_WIF_HERE")?;
62//!     
63//!     // Initialize the bridge contract
64//!     let bridge = NeoXBridgeContract::new(Some(&neo_client));
65//!     
66//!     // Get the GAS token script hash
67//!     let gas_token = ScriptHash::from_str("d2a4cff31913016155e38e474a2c06d08be276cf")?;
68//!     
69//!     // Deposit GAS from Neo N3 to Neo X
70//!     let neo_x_address = "0x1234567890123456789012345678901234567890";
71//!     let amount = 1_0000_0000; // 1 GAS
72//!     
73//!     let deposit_tx = bridge.deposit(
74//!         &gas_token,
75//!         amount,
76//!         neo_x_address,
77//!         &account,
78//!     ).await?;
79//!     
80//!     println!("Deposit transaction sent: {}", deposit_tx.hash());
81//!     
82//!     Ok(())
83//! }
84//! ```
85
86pub mod bridge;
87pub mod evm;
88
89pub use bridge::*;
90pub use evm::*;