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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use FromStr;
use cratePubkey;
/// Represents a blockchain instruction to be executed by a specific program.
///
/// An instruction contains:
/// - The program ID that will process this instruction
/// - A list of accounts that will be accessed during execution
/// - Instruction-specific data encoded as bytes
///
/// # Examples
///
/// ```
/// use rialo_cdk::transaction::instruction::{Instruction, AccountMeta};
/// use rialo_cdk::rpc::types::Pubkey;
/// use std::str::FromStr;
///
/// let program_id = Pubkey::from_str("11111111111111111111111111111111").unwrap();
/// let instruction = Instruction {
/// program_id,
/// accounts: vec![/* account metadata */],
/// data: vec![/* encoded instruction data */],
/// };
/// ```
/// Metadata for an account that will be accessed by an instruction.
///
/// This structure defines how an account will be used within an instruction:
/// - Which account (via its public key)
/// - Whether it's required to sign the transaction
/// - Whether the program will write to this account
///
/// # Examples
///
/// ```
/// use rialo_cdk::transaction::instruction::AccountMeta;
/// use rialo_cdk::rpc::types::Pubkey;
/// use std::str::FromStr;
///
/// let pubkey = Pubkey::from_str("11111111111111111111111111111111").unwrap();
/// let account_meta = AccountMeta {
/// pubkey,
/// is_signer: true,
/// is_writable: false,
/// };
/// ```
/// Creates a transfer instruction for the System Program.
///
/// This function builds an instruction that transfers `kelvin` from one account to another
/// using the System Program. Both the sender and receiver accounts are specified by their
/// base58-encoded public keys.
///
/// # Arguments
///
/// * `from` - Base58-encoded public key of the sender account (must be a signer)
/// * `to` - Base58-encoded public key of the recipient account
/// * `kelvin` - Amount of kelvin (the smallest unit of currency) to transfer
///
/// # Returns
///
/// An `Instruction` that can be included in a transaction to perform the transfer
///
/// # Examples
///
/// ```
/// use rialo_cdk::transaction::instruction::transfer_instruction;
/// use rialo_cdk::rpc::types::Pubkey;
/// use std::str::FromStr;
///
/// let from_address = Pubkey::from_str("11111111111111111111111111111112").unwrap();
/// let to_address = Pubkey::from_str("11111111111111111111111111111113").unwrap();
/// let amount = 1_000_000; // kelvin
///
/// let transfer_ix = transfer_instruction(&from_address, &to_address, amount);
/// // Include this instruction in a transaction to execute the transfer
/// ```