0

i saw TweetNacl-js library in Solana-Coookbook and if i want to sign signature in client side and sign the transaction and send it to solana smart contract. Is there a way? if i consider to use ED25519 Program.. how should i proceed?

1 Answer 1

0

Unfortunately, you can't call the ed25519 program directly from your smart-contract. You need to include an instruction to the program at the toplevel, ie:

        let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
        let message_arr = b"hello";
        let mut instruction = new_ed25519_instruction(&privkey, message_arr);
        let mint_keypair = Keypair::new();

        let tx = Transaction::new_signed_with_payer(
            &[instruction.clone()],
            Some(&mint_keypair.pubkey()),
            &[&mint_keypair],
            Hash::default(),
        );

Copied from the rust tests at https://github.com/anza-xyz/agave/blob/8f9fc2ada2396fc1e41a7393e9ac8714635d3107/sdk/src/ed25519_instruction.rs#L347

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.