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
use CpiContext;
use AccountInfo;
use Pubkey;
use Key;
use ;
use ;
use invoke_signed;
pub use ID;
use crate;
/// Mints new SPL tokens with associated metadata.
///
/// This function creates metadata for a new token using the `mpl_token_metadata`
/// program, and mints the specified number of tokens to the `to` account.
///
/// # Arguments
///
/// * `token_name` - The name of the token to be minted.
/// * `token_symbol` - The symbol for the token.
/// * `token_uri` - A URI pointing to the token's metadata (e.g., hosted image or metadata information).
/// * `token_tax` - The seller fee basis points (bps) for token transactions.
/// * `payer` - The account responsible for paying transaction fees.
/// * `token_metadata_program` - The account for the token metadata program.
/// * `update_authority` - The account authorized to update the token's metadata.
/// * `metadata` - The metadata account for the token.
/// * `mint_authority` - The account authorized to mint the tokens.
/// * `system_program` - The system program account.
/// * `rent` - The rent sysvar account.
/// * `token_program` - The SPL token program account.
/// * `mint` - The token mint account.
/// * `to` - The account where the minted tokens will be transferred to.
/// * `owner` - The owner of the `to` account.
/// * `signer_seeds` - The seeds used to sign the transaction.
/// * `amount` - The number of tokens to mint.
///
/// # Example
///
/// ```rust
/// use simplespl::mint_simple;
/// use anchor_lang::solana_program::account_info::AccountInfo;
///
/// let result = mint_simple(
/// "TokenName".to_string(),
/// "TKN".to_string(),
/// "https://example.com/token-metadata".to_string(),
/// 500, // 5% seller fee
/// payer_account_info,
/// token_metadata_program_info,
/// update_authority_info,
/// metadata_account_info,
/// mint_authority_info,
/// system_program_info,
/// rent_sysvar_info,
/// token_program_info,
/// mint_account_info,
/// to_account_info,
/// owner_account_info,
/// &[&signer_seeds],
/// 1000 // Mint 1000 tokens
/// ).unwrap();
/// ```
/// Creates metadata for a token using the `mpl_token_metadata` program.
///
/// This function sets up the metadata for a token, including its name, symbol, URI,
/// seller fee, and creator information. It also uses the provided `signer_seed` for
/// signing the metadata creation transaction.
///
/// # Arguments
///
/// * `token_name` - The name of the token.
/// * `token_symbol` - The symbol of the token.
/// * `token_uri` - A URI that points to the token metadata.
/// * `token_tax` - The seller fee in basis points (bps).
/// * `payer` - The account paying for the transaction.
/// * `token_metadata_program` - The token metadata program account.
/// * `update_authority` - The account authorized to update the metadata.
/// * `mint` - The mint account for the token.
/// * `metadata` - The metadata account.
/// * `mint_authority` - The account authorized to mint the tokens.
/// * `system_program` - The system program account.
/// * `rent` - The rent sysvar account.
/// * `signer_seed` - A slice of slices of seeds for signing the metadata creation transaction.
///
/// # Example
///
/// ```rust
/// use simplespl::metadata_thing;
/// use anchor_lang::solana_program::account_info::AccountInfo;
///
/// metadata_thing(
/// "TokenName".to_string(),
/// "TKN".to_string(),
/// "https://example.com/token-metadata".to_string(),
/// 500, // 5% seller fee
/// payer_account_info,
/// token_metadata_program_info,
/// update_authority_info,
/// mint_account_info,
/// metadata_account_info,
/// mint_authority_info,
/// system_program_info,
/// rent_sysvar_info,
/// &[&signer_seed],
/// ).unwrap();
/// ```
/// Transfers SPL tokens from one account to another.
///
/// This function facilitates the transfer of SPL tokens between accounts
/// on the Solana blockchain. It uses the `spl_token::instruction::transfer` function
/// to create the transfer instruction, and signs the transaction using the provided
/// `signer_seeds`.
///
/// # Arguments
///
/// * `mint` - The mint account of the token.
/// * `token_program_id` - The token program account (usually `spl_token`).
/// * `source_pubkey` - The source account's public key from which tokens will be transferred.
/// * `destination_pubkey` - The destination account's `AccountInfo`.
/// * `authority_pubkey` - The authority account that will sign the transfer.
/// * `amount` - The amount of tokens to transfer.
/// * `signer_seeds` - A slice of slices of seeds for signing the transaction.
///
/// # Example
///
/// ```rust
/// use simplespl::transfer_simple;
/// use anchor_lang::solana_program::account_info::AccountInfo;
///
/// transfer_simple(
/// mint_account_info,
/// token_program_account_info,
/// source_pubkey,
/// destination_account_info,
/// authority_account_info,
/// 500, // Transfer 500 tokens
/// &[&signer_seeds],
/// ).unwrap();
/// ```
/// Burns SPL tokens from an account.
///
/// This function allows you to burn (destroy) a specified number of SPL tokens from
/// a source account. The transaction is signed using the provided `signer_seeds`.
///
/// # Arguments
///
/// * `mint` - The mint account of the token.
/// * `token_program_id` - The token program account (usually `spl_token`).
/// * `source_pubkey` - The account from which tokens will be burned.
/// * `authority_pubkey` - The account authorized to burn the tokens.
/// * `amount` - The amount of tokens to burn.
/// * `signer_seeds` - A slice of slices of seeds for signing the transaction.
///
/// # Example
///
/// ```rust
/// use simplespl::burn_simple;
/// use anchor_lang::solana_program::account_info::AccountInfo;
///
/// burn_simple(
/// mint_account_info,
/// token_program_id,
/// source_account_info,
/// authority_account_info,
/// 1000, // Burn 1000 tokens
/// &[&signer_seeds],
/// ).unwrap();
/// ```