Solana: Solana playground: Deployed token has no image and metadata and ({“err”:{“InstructionError”:[2,”AccountNotExecutable”]}})

I can help you with that. However, I need more information about your project and the specific error message you’re experiencing. HERE’S A SAMPLE ARTICLE based on what you’ve provided:

Solana Playground: Deploying token with Unexecutable Account

In this article, we will explore an issue related to deploying a token on the solana blockchain using anchor, a popular framework for building decentralized applications (dapps).

Lib.rs

Solana: Solana playground: Deployed token has no image and metadata and ({

`rust

Use Anchor_lang :: Prelude ::*;

Use anchor_spl :: {

Associated_token :: AssociatedToken,

Metadata :: {Create_Metadata_accounts_V3},

};

#[Anchor Contract]

my_contract mode {

Use super ::*;

#[Program]

PUB FN create_token (_info: programinfo) -> Result <(), InstructionError> {

// Create an AssociatedToken for the Deployed Token

Let token = Associatedtoken :: NEW (“My Token”, “Mtoken”, 1_000_000_000);

// create metadata accounts for the token

let accounts = create_metadata_accounts_v3 (& token, & [123]);

OK (())

}

}

`

Error

`JSon

{

"Type": "Err",

"msg": "InstructionError: Account Not Executable",

"Date": {

"instruction_id": "create_token",

"Accounts": {

"token": {

"Date": null,

"Key": "0x ..."

},

"metadata_accounts_v3": [

...

]

}

}

}

Solution

In this example, the create_metadata_accounts_v3 function is called with an empty array of accounts. To fix this issue, we need to specify the account that will be executed by Anchor’s Compiler. This account should have a unique key (e.g., “0x …”) and a corresponding contract address.

To fix the issue in the My_contract.rs file, we need to add the following line to theCreate_token 'Function:

rust

let execution_info = programminfo :: NEW ();

let contract_address = execution_info.account_key (). As_str (). Unwrap_or (“0x …”);

let account = “0x …”; // Replace with a valid account key

// Create metadata accounts for the token

let accounts = create_metadata_accounts_v3 (& token, & [Account]);

OK (())

`

Full Code

Here’s the full code with the corrected My_contract.rs File:

`rust

Use Anchor_lang :: Prelude ::*;

Use anchor_spl :: {

Associated_token :: AssociatedToken,

Metadata :: {Create_Metadata_accounts_V3},

};

#[Anchor Contract]

my_contract mode {

Use super ::*;

#[Program]

PUB FN create_token (_info: programinfo) -> Result <(), InstructionError> {

// create an associatedtoken for the deployed token

Let token = Associatedtoken :: NEW (“My Token”, “Mtoken”, 1_000_000_000);

// create metadata accounts for the token

let execution_info = programminfo :: NEW ();

let account = “0x …”; // Replace with a valid account key

let contract_address = execution_info.account_key (). As_str (). Unwrap_or (“0x …”);

let accounts = create_metadata_accounts_v3 (& token, & [Account]);

OK (())

}

}

`

Notes

  • Make sure to replace the account variable in the` create_token ‘function with a valid account key.

  • This example assumes that you have already set up your solana development environment and have installed the necessary dependencies (E.G., Anchor, Anchor Spl).

  • This is just an example code snippet, and you should consult the official documentation for anchor and also spl for more information on how to deploy tokens on the solana blockchain.

IMPACT IMPACT INTELLIGENCE CRYPTOCURRENCY ENERGY

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *