Skip to main content

read_program_id_at

Function read_program_id_at 

Source
pub fn read_program_id_at(
    sysvar_data: &[u8],
    index: u16,
) -> Result<[u8; 32], ProgramError>
Expand description

Read the program_id of instruction at the given index.

Instructions sysvar layout:

[u16 num_instructions]
[u16 offset_0] [u16 offset_1] ... [u16 offset_{n-1}]  <-- offset table
[serialized instruction 0]
[serialized instruction 1]
...
[u16 current_instruction_index]  <-- last 2 bytes

Per-instruction layout at sysvar_data[offset]:

[u16 num_accounts]
[u8 flags + [u8; 32] pubkey] * num_accounts  (33 bytes each)
[u8; 32] program_id
[u16 data_len]
[u8; data_len] data