Last active
February 25, 2025 21:23
-
-
Save belivenn/2766ca011c611d66be6e57a333b53bf2 to your computer and use it in GitHub Desktop.
metadata.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use mpl_token_metadata::{instruction::create_metadata_accounts_v3, state::Creator as creator_struct}; | |
pub fn create_metadata(&mut self, name: String, symbol: String, uri: String) -> Result<()> { | |
let seeds = &[ | |
&b"creator"[..], | |
&self.creator.tweet_id.to_le_bytes()[..], | |
&[self.creator.state_bump], | |
]; | |
let program_id = self.metadata_program.key(); | |
let metadata = self.metadata.key(); | |
let mint = self.mint.key(); | |
let mint_authority = self.creator.key(); | |
let payer = self.pool_creator.key(); | |
let create_metadata_ix = create_metadata_accounts_v3( | |
program_id, | |
metadata, | |
mint, | |
mint_authority, | |
payer, | |
mint_authority, | |
name, | |
symbol, | |
uri, | |
Some(vec![creator_struct { | |
address: mint_authority, | |
verified: true, | |
share: 100, | |
}]), | |
0, | |
false, | |
false, | |
None, | |
None, | |
None, | |
); | |
invoke_signed( | |
&create_metadata_ix, | |
&[ | |
self.metadata.to_account_info(), | |
self.mint.to_account_info(), | |
self.creator.to_account_info(), | |
self.pool_creator.to_account_info(), | |
self.creator.to_account_info(), | |
self.system_program.to_account_info(), | |
self.rent_program.to_account_info(), | |
], | |
&[&seeds[..]], | |
)?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment