How to wriite in Solana Blockchain

Hello, i would like to create a tranaction and pass a json in this transaction ?
I can’t find the function.

Thanks all

Writing Solana transactions is a little complicated right now. You could check out the Anchor project and their guide, which is like a much, much easier way to write Solana contracts.

The issue I’ve had with Anchor is that it was buggy ( or I was just confused at the error message ) when I tried to do more complicated stuff, and it’s also very new so it’s design might change quite a bit over time.

If you don’t want to use Anchor for any reason, you can do it yourself just using the solana program, but it’s rather involved, and an in-depth tutorial may be necessary to actually explain it.

The short version that just explains the Rust side of things is that the program entrypoint will have a data argument that is a slice of bytes ( &[u8] ):

/ Declare and export the program's entrypoint

// Program entrypoint's implementation
pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8], // This data will be your JSON bytes
) -> ProgramResult {
    msg!("Hello World Rust program entrypoint");
    // Parse the JSON using a Rust JSON parsing library like miniserde maybe

You just have to parse that JSON in your transaction, but you probably don’t want to use normal serde because it is large and will take up extra space on the blockchain and extra compute units that aren’t necessary.

This is one reason why Borsh serialization is more common with Solana contracts, but Borsh serialization is not as easy to do in JavaScript when sending the transaction.

I don’t have time now to go more in-depth, but I might write a tutorial some time if I can find the time.