forked from solana-developers/program-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdk.rs
More file actions
39 lines (37 loc) · 1.04 KB
/
sdk.rs
File metadata and controls
39 lines (37 loc) · 1.04 KB
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
use crate::prelude::*;
use steel::*;
pub fn create_token(
signer: Pubkey,
mint: Pubkey,
name: [u8; 32],
symbol: [u8; 8],
uri: [u8; 128],
decimals: u8,
) -> Instruction {
Instruction {
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(mint, true),
AccountMeta::new(metadata_pda(mint).0, false),
AccountMeta::new_readonly(system_program::ID, false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(mpl_token_metadata::ID, false),
AccountMeta::new_readonly(sysvar::rent::ID, false),
],
data: CreateToken {
name,
symbol,
uri,
decimals,
}
.to_bytes(),
}
}
// Fetch PDA of a metadata account.
pub fn metadata_pda(mint: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[METADATA, mpl_token_metadata::ID.as_ref(), mint.as_ref()],
&mpl_token_metadata::ID,
)
}