neo3/neo_x/evm/
transaction.rs

1use async_trait::async_trait;
2use primitive_types::H160;
3use serde::{Deserialize, Serialize};
4use std::str::FromStr;
5
6/// Neo X EVM transaction for interacting with the Neo X EVM-compatible chain
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct NeoXTransaction {
9	to: Option<H160>,
10	data: Vec<u8>,
11	value: u64,
12	gas_limit: u64,
13	gas_price: u64,
14}
15
16impl NeoXTransaction {
17	/// Creates a new NeoXTransaction instance
18	///
19	/// # Arguments
20	///
21	/// * `to` - The recipient address (None for contract creation)
22	/// * `data` - The transaction data
23	/// * `value` - The transaction value
24	/// * `gas_limit` - The gas limit for the transaction
25	/// * `gas_price` - The gas price for the transaction
26	///
27	/// # Returns
28	///
29	/// A new NeoXTransaction instance
30	pub fn new(
31		to: Option<H160>,
32		data: Vec<u8>,
33		value: u64,
34		gas_limit: u64,
35		gas_price: u64,
36	) -> Self {
37		Self { to, data, value, gas_limit, gas_price }
38	}
39
40	/// Gets the recipient address
41	///
42	/// # Returns
43	///
44	/// The recipient address as an Option<H160>
45	pub fn to(&self) -> Option<H160> {
46		self.to
47	}
48
49	/// Gets the transaction data
50	///
51	/// # Returns
52	///
53	/// The transaction data as a Vec<u8>
54	pub fn data(&self) -> &Vec<u8> {
55		&self.data
56	}
57
58	/// Gets the transaction value
59	///
60	/// # Returns
61	///
62	/// The transaction value as a u64
63	pub fn value(&self) -> u64 {
64		self.value
65	}
66
67	/// Gets the gas limit for the transaction
68	///
69	/// # Returns
70	///
71	/// The gas limit as a u64
72	pub fn gas_limit(&self) -> u64 {
73		self.gas_limit
74	}
75
76	/// Gets the gas price for the transaction
77	///
78	/// # Returns
79	///
80	/// The gas price as a u64
81	pub fn gas_price(&self) -> u64 {
82		self.gas_price
83	}
84}