Solana: The smart contract runs fine on the Solana Playground, but gives error on my local machine.(not found in this scope)
Sorana: Intelligent Agreement works well at the Sorano playground but gives an error on a local machine
As a smart contract programmer, especially for popular platforms, such as Ethereum and Sorana, it is necessary to ensure that your code is assembled and works properly in different environments. In this article, we explored what went wrong with a simple voting agreement written in Rust, which went smoothly at the Soran playground but did not start on my local machine.
Command
Our intelligent agreement is designed to create an interactive research app in which users can prefer to vote for the script. The agreement uses Solana SDK (Packaging S It is written in rust and most functions are performed using a subscription to the «Soran-Program» app.
Here’s a brief overview of the agreement:
`rust
Use Solan_ Process :: {{
Account_info :: Next_account_info,
EntryPoint :: {Get_event_address, call},
Msg,
Program_error :: {program
PubKey :: Pubkey,
};
Use Solan_sdk :: {{
Error :: Error as Solanerror,
Keypair :: keyboard,
Transaction :: {Sami, dedication, preparationsactionerror},
};
// Function to create a new research
Pub Fn Create_pon (
PubKey: & PubKey,
Result: string,
) -> Programsult
// Create a new survey manifestation
Allow me to bother = pool :: new ();
Pool.set_outcom (result);
// Get the following account information information
Enter user_account_info = pool.get_next_account_info (). Wait?;
Let Account_keypair = User_account_info.KEY;
// Call the Create_poll
function to the user account
reconcile (
& Account_keypair,
Create_poll_callback,
& Pool,
& [[
Account_keypair,
Next_account_info (),
],].
Dedication :: Finally,
IN
Iche
// Function to update the survey results
Pub fn update_poll (end result: string) -> program-
// Update the questionnaire with a new result
Allow me to bother = pool :: new ();
Pool.set_outcom (result);
// Get the following account information information
Enter user_account_info = pool.get_next_account_info (). Wait?;
Let Account_keypair = User_account_info.KEY;
// call the Update_poll
function in the user account
reconcile (
& Account_keypair,
Update_poll_callback,
& Pool,
& [[
Account_keypair,
Next_account_info (),
],].
Dedication :: Finally,
IN
Iche
// Inquiring Creation and Update Function of Refund
Pub Fn Create_poll_callback (
Account_info: & Accountinfo,
Pool: and pool,
) -> Programsult
// Create a new survey manifestation
Allow me to bother = pool :: new ();
Swimming pool
Ok (obligation :: Finally)
Iche
Pub fn update_poll_callback (
Account_info: & Accountinfo,
Pool: and pool,
) -> Programsult
// Update the questionnaire with a new result
Allow me to bother = pool :: new ();
Pool.Set_outcom (Account_info.data.Borrow (). As_str ())?;
Ok (obligation :: Finally)
Iche
`
Problem
On my local machine I met a mistake that prevented me from completing my contract. The error message was quite mysterious:
ERROR: UNDEDED TYPE 'Program
Not found to this extent
While checking the code more details, we can see thatCreate_poll_callbackI
Update_poll_Callback` will restore the» Program Program «defined by Sorana SDK. However, there is no explicit definition of type.
Solution
To correct the topic, I have made two changes in the contract:
1.