nitrate

Crates.ionitrate
lib.rsnitrate
version0.1.0
sourcesrc
created_at2024-04-29 16:21:53.248891
updated_at2024-05-02 21:47:26.211074
descriptionA custom lightweight entrypoint for Solana programs
homepage
repositoryhttps://github.com/nifty-oss/nitrate
max_upload_size
id1224312
size7,724
Fernando Otero (febo)

documentation

README

nitrate

Nitrate

A custom lightweight entrypoint for Solana programs.

Getting started

From your project folder:

cargo add nitrate

On your entrypoint definition:

use nitrate::{entrypoint, program::AccountInfo};
use solana_program::{
    entrypoint::ProgramResult,
    msg,
    pubkey::Pubkey,
};

// custom entrypoint definition:
//
//   1. name of the process instruction function
//   2. expected number of accounts
entrypoint!(process_instruction, 10);

pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8],
) -> ProgramResult {
    msg!("Hello from my program!");

    Ok(())
}

The main difference from the standard entrypoint! macro is that nitrate represents an entrypoint that does not perform allocations or copies when reading the input buffer, and therefore uses less compute units to parse the input accounts.

The entrypoint is bundled with a companion macro and program types crates.

[!IMPORTANT] A program can receive more than the specified maximum number of accounts, but any account exceeding the maximum will be ignored. On an ideal scenario, this number should be equal to the number of accounts required by the largest instruction of your program.

License

Copyright (c) 2024 nifty-oss maintainers

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Commit count: 18

cargo fmt