I can’t help you with this request. Solana: How to turn away from account to inemitheckcount?
You are developing within the anchor and you have a problem with tokens accounts. I can suggest an alternative:
What about this article?
pretending Accountinfo
Uncheckcountin Anchorage
When working with an anchor, you must often perform operations that require access to your account data. However, "Accountinfo" is a type of low level that provides a lot of information about the current account status. In some cases, you could turn it into a “ineecount” that offers more practical and security features.
In this article we will examine how to achieve this conversion to Anchorage.
assumptions
Before you dive into the code, make sure you have the following addiction installed:
- Anchor_lang
: Official Sadra
- Anchor_spl
: Solana SDK to anchor
You can add this addiction to your fileload:
`Toml
[Dependence]
Anchor-lang = "0.1.6"
Anchor-spl = "0.31.8"
during conversion
Here is an example of how you can convertaccountinfo uncheckcount ‘in Anchorage:
`rust
Use anchor_lang :: Prelude ::*;
#[Make accounts, clone)]
Pub Struct AccountinfotouNCACCOUNT (
PUBKEY: Signators,
#[Account (
Has_one = owner,
Necessary = true,
List = Accounts,
))
UNHOCKEDACOUNT: UNCOCKOUTACCOUNT,
);
ImplcinfotouCacCount {
Fn Get_uncheked_accoun (& self) -> Uncheckeccount {
Self.0.To_unCHEKED_ACCOUNT ()
Shore
Shore
Pub Fn Accounts_info_tounchecked_account (
Information: Accountinfo,
Token_program: Programmide,
Accounts: & Btremep
): Result
// Create instructions to transfer your account data
Leave the instructions = instruction :: new (
“Convert_accoun_info”,
& [info.pubkey],
[
AccountinfotouncccCount {
PUBKEY: Info.pubkey,
#[Account (
Has_one = owner,
Necessary = true,
List = Accounts,
))
UNCHEKED_ACCOUNT: INFO.GET_UNCHEKED_ACCOUNT ().
Mozhlo
. “”
);
// Create a new account program
Let New_program_id = Programmide :: New (“my_new_program”, “New_ Program”);
// perform the instructions for the local blockchain
If you leave it sin (err) = anchor_lang :: program :: new (program_id, instructions)?;
If! err.is_ok () {{{{{
Return ERR (ERR);
Shore
// Return a new Account ID program
OK (New_program_id.into ())
Shore
`
Explanation
In this example, we create the structure of theaccountinfotouncceccCountwith one field, which is the owner of the original account. Then we use the "Get_unchecked_acCount
to download “UNSCHECKECKOUNT.
Theaccount_info_tounchecked_accounaccounted 'is taken as an Accountinfo' entrance,
token_programAccount
. This creates instructions to convert your account data using the “Instructional function:
The instruction is then created by transferring the original account information, ID I and an instance uncheckcount
that we want to download. Finally, we perform instructions on the local blockchain using anchor_lang :: New
. If the execution fails, we will return the error; Otherwise we will return the new account ID.