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
use Arc;
use ;
use Transaction;
use ;
use ;
use crateerror;
/// Constructs a signed transaction from a set of instructions and signers
///
/// This method creates a transaction with the provided instructions and signers,
/// obtaining a recent blockhash from the Solana network. It handles the process
/// of creating a properly formed transaction that can be submitted to the network.
///
/// # Arguments
///
/// * `rpc` - An Arc-wrapped RpcClient used to fetch the recent blockhash
/// * `payer` - The primary account that will pay for the transaction fees
/// * `instructions` - Slice of Solana instructions to include in the transaction
/// * `additional_signers` - Optional slice of additional keypair signers that should sign the transaction,
/// in addition to the payer
/// * `address_lookup_table_accounts` - Optional slice of Address Lookup Table accounts to include,
/// enabling versioned transactions with address table lookups
/// (only available with "versioned-tx" feature)
///
/// # Returns
///
/// Returns a signed Transaction (or VersionedTransaction when the "versioned-tx" feature is enabled)
/// if successful, or a ClientError if the operation fails
///
/// # Errors
///
/// Returns an error if:
/// - Failed to retrieve the recent blockhash from the network
/// - Transaction creation fails due to invalid parameters
/// - Transaction message compilation fails (for versioned transactions)
/// - Transaction signing fails
///
/// # Feature flags
///
/// When compiled with the "versioned-tx" feature, this function returns a VersionedTransaction
/// that supports Address Lookup Tables. Otherwise, it returns a standard Transaction.
///
/// # Examples
///
/// ```no_run
/// # use pumpfun::{
/// # common::types::{Cluster, PriorityFee},
/// # utils::transaction::get_transaction,
/// # PumpFun,
/// # };
/// # use solana_sdk::{
/// # commitment_config::CommitmentConfig, instruction::Instruction,
/// # message::AddressLookupTableAccount, signature::Keypair,
/// # };
/// # use std::sync::Arc;
/// #
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// # let payer = Arc::new(Keypair::new());
/// # let cluster = Cluster::devnet(CommitmentConfig::confirmed(), PriorityFee::default());
/// # let client = PumpFun::new(payer, cluster);
/// # let instructions: Vec<Instruction> = Vec::new();
/// # let custom_signer = Keypair::new();
/// #
/// // Create a transaction with multiple signers
/// let transaction = get_transaction(
/// client.rpc.clone(),
/// client.payer.clone(),
/// &instructions,
/// Some(&[&custom_signer]),
/// # #[cfg(feature = "versioned-tx")]
/// # None,
/// )
/// .await?;
///
/// // Or with just the payer as signer
/// let transaction = get_transaction(
/// client.rpc.clone(),
/// client.payer.clone(),
/// &instructions,
/// None,
/// # #[cfg(feature = "versioned-tx")]
/// # None,
/// )
/// .await?;
///
/// // Create a versioned transaction with address lookup tables (when "versioned-tx" feature is enabled)
/// let lookup_tables: Vec<AddressLookupTableAccount> = Vec::new();
/// let transaction = get_transaction(
/// client.rpc.clone(),
/// client.payer.clone(),
/// &instructions,
/// None,
/// # #[cfg(feature = "versioned-tx")]
/// Some(&lookup_tables),
/// )
/// .await?;
/// Ok(())
/// # }
/// ```
pub async