I can help you with that. However, I need more information about your project and the specific error message you are experiencing. Here is a test item based on what you offered:
Sola PlayGround: Implementation of the token with a non -executable account
In this article, we will explore a problem related to the implementation of a token on the Sola Blockchain using ANCHOR, a popular framework for the construction of decentralized applications (DAPPS).
lib.rs
`Rust
Use anchor_lang :: take ::*;
Use anchor_spl :: {
Associated_Token :: AssociatedToken,
Metadate :: {Create_Metata_accounts_v3},
};
#[Anchor contract]
MY MY_CONTRACT {
Use super ::*;
#[program]
pub fn created_token (_info: programminfo) -> result <(), instructions> {
// Create an associate for implemented token
Let token = AssociatedToKen :: New ("my token", "mtoken", 1_000_000_000);
// create metadata accounts for the token
let accounts = created_metata_accounts_v3 (& token, & [123]);
Well (())
}
}
Error
Json
{
"Type": "err",
"MSG": "Instructions: Account is not executable",
"data": {
"InstruT_id": "Create_token",
"accounts": {
"token": {
"Data": null,
"key": "0x ..."
},
"Metata_accounts_v3": [
... ...
]
}
}
}
Solution
In this example, the functioncreate_metata_accounts_v3is called with a empty series of accounts. In order to remedy this problem, we must specify the account that will be executed by the Anchor compiler. This account should have a unique key (for example, "0x ...") and an appropriate contractual address.
To fix the problem in themy_contract file.
`Rust
let executor_info = programinfo program :: 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 = created_metata_accounts_v3 (& token, & [account]);
Well (())
Complete code
Here is the full code with the file correctedmy_contract.rs:
Rust
Use anchor_lang :: take ::*;
Use anchor_spl :: {
Associated_Token :: AssociatedToken,
Metadate :: {Create_Metata_accounts_v3},
};
#[Anchor contract]
MY MY_CONTRACT {
Use super ::*;
#[program]
pub fn created_token (_info: programminfo) -> result <(), instructions> {
// Create an associate for implemented token
Let token = AssociatedToKen :: New ("my token", "mtoken", 1_000_000_000);
// create metadata accounts for the token
let executor_info = programinfo program :: new ();
Let account = "0x ..."; // replace with a valid account key
let contract_address = execution_info.account_key (). as_str (). Unwrap_or ("0x ...");
let accounts = created_metata_accounts_v3 (& token, & [account]);
Well (())
}
}
Notes
- Make sure you replace the` in -Create_tokena function with a valid account key.
- This example assumes that you have already configured the solar development environment and have installed the necessary addictions (for example, anchor, SPL anchor).
- This is just an example of a code fragment and you should consult the official documentation for Anchor and Anchor SPL for more information on how to implement chips on Blockchain Solana.