-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_sol.rs
33 lines (28 loc) · 978 Bytes
/
check_sol.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint,
entrypoint::ProgramResult,
msg,
pubkey::Pubkey,
};
/// Program entrypoint
entrypoint!(process_instruction);
/// Process the instruction
pub fn process_instruction(
_program_id: &Pubkey, // Program ID
accounts: &[AccountInfo], // Accounts passed in
_instruction_data: &[u8], // Instruction data
) -> ProgramResult {
// Parse the account information
let account_info_iter = &mut accounts.iter();
let account_to_check = next_account_info(account_info_iter)?;
// Ensure the account is a valid signer
if !account_to_check.is_signer {
msg!("The provided account is not a signer.");
return Err(solana_program::program_error::ProgramError::MissingRequiredSignature);
}
// Get the account's balance
let lamports = account_to_check.lamports();
msg!("The account balance is: {} lamports", lamports);
Ok(())
}