导入 anchor
use anchor_lang::prelude::*;
declare_id!("public_key");
#[program]
宏创建我们的 program(合约)
#[program]
mod hello_world {
use super::*;
pub fn hello(ctx: Context<Hello>) -> Result<()> {
Ok(())
}
}
Rust println!
→ Anchor msg!
msg!("Hello, World!");
给结构体派生 [derive(Accounts)]
来定义 Account
#[derive(Accounts)]
pub struct Hello {}
Context
build & deploy
IDL
anchor_spl
& mpl_token_metadata
use anchor_spl::{
associated_token::AssociatedToken,
metadata::{create_metadata_accounts_v3, CreateMetadataAccountsV3, Metadata},
token::{burn, mint_to, Burn, Mint, MintTo, Token, TokenAccount},
};
use mpl_token_metadata::{pda::find_metadata_account, state::DataV2};
use solana_program::{pubkey, pubkey::Pubkey};
RPC
端点将其发送到 Solana 集群