Solana: Accounts required by solana native instructions

Solana natival instruction on the creation of tokens: hand -breeding

How to work out with solana, the creation of local tokens can be a timber process. In this state, we dissatisfied with the creation of the tokens on the blockchain solana with the use of nativity instruction.

What is the native instruction?

In the Solana Local Instructions – this special program, which allows the stretching of the distilled tasks, such as mining and transfer, without the need for a traditional intake. They introduce the more brief and efficient impact of the reolization and the token in the Solana network.

Create tokens with CreateTokens

Createtokens’ instruction is used for the creation of new tokens on the solana blockchain. To use this instruction, you need:

  • Installation of the non-existent exposure : You need to install the “Solana-Program” lust, which introduces the adjacent instruction and the connected utilites.

  • Submit SOLANA

    Solana: Accounts required by solana native instructions

    The program must have the following structure:

`Rust

Use Soolana_program :: {

Account_info :: {NEXT_ACCOUN_INFO, Accountinfo},

IntryPoint,

IntryPoint :: Programresult,

Program_error :: PRINTPROGRIMERROR,

PUBKEY :: PUBKY,

};

Use STD :: Convert :: From;

Struct tokencreator {

Pub key: Pubkey,

}

Impl Tokencreator {

FN NEW (Key: Pubkey) -> Self {

Self {key}

}

}

3.

`Rust

FN CREATE_TOKENS (

Program_id: & Pubkey,

Cutting: & [Accountinfo],

Methalist: Accountinfo,

) -> Programresult {

/

Let Mut Account_info = Next_account_info (UCHED RULES [0])?;

// Create a new cottage token

Let New_token_account = Create_token_account (

Program_id,

& Account_info,

and metadanic,

1, // Mint sadness

)?;

Good (())

}

4.

`Toml

[Availabicity]

Solana-Program = “1.13.2”

`

  • Cringer your own instruction with your program

    : thrust installed with your program solan

`Rust

#[program]

MOD SOLANA_PROGRAM {

Use Soolana_program :: {

Account_info :: {NEXT_ACCOUN_INFO, Accountinfo},

IntryPoint,

IntryPoint :: Programresult,

Program_error :: PRINTPROGRIMERROR,

PUBKEY :: PUBKY,

};

Use Crate :: Token_Creator :: Create_Tokens;

FN MAIN () -> Programresult {

// ...

}

IntryPoint! (Create_tokens);

FN CREATE_TOKEN_ACCOUNT (

Program_id: & Pubkey,

Account_info: Accountinfo,

Methalist: Accountinfo,

Mint_amount: U64,

) -> Result <_, PRINTPROGRAMROR> {

// ...

}

}

Creation of tokens with instruction transfertokens

To overone tokens, you can use the “transfertokens” instruction. To make a new token for transition, you need to change the program with the following image:

  • Submit a new function for transfer tokens : Add a new function in your program that relates to instruction transfertokens:

`Rust

fn transfer_tokens (

Program_id: & Pubkey,

Cutting: & [Accountinfo],

Methalist: Accountinfo,

) -> Programresult {

/

Let Mut Account_info = Next_account_info (UCHED RULES [0])?;

// Create a new coded token for transfer

Let New_token_account = Create_token_account (

Program_id,

& Account_info,

and metadanic,

1, // Mint sadness

)?;

Good (())

}

  • Zaregistrine Instruction Transfertokens : In your cargo.

algorithms algorithms energy waste cryptocurrency

Bài viết liên quan

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *