I am writing a frame where I need to generate the vrf sign for the authority, this requires me to include the sp_keystore and schnorrkel in the cargo.toml of the frame. enter image description here

But then I encounter the following errors:-

enter image description here enter image description here

As you can see there are some conflicts between std and no_std types. I understand that we cannot use std library inside the frame. Is there any way to use these crates inside frame?

What I want to do is something like the following

    let result = SyncCryptoStore::sr25519_vrf_sign(

This works for the client. But I need to do this inside frame and have SyncCryptoStore and Keystore be accessible inside the frame.

EDIT: The solution is to use or write a host function to access client code from within the runtime/frame.

Thank you, Yeou

1 Answer 1


You won't have access to the keystore from within a pallet since the keystore will include state that isn't tracked in the blockchain (i.e. the keys that are stored in the keystore). Allowing access to the keystore would lead to non-determinism since the pallet would execute differently depending on what keys the users had on disk. Even if you work around this by creating an host function you will just introduce non-determinism into your runtime which will lead to consensus issues.

It is possible to use the keystore from within the runtime but only for offchain workers. Have a look at the offchain worker for the im-online pallet since it does sign stuff with keys from the keystore (https://github.com/paritytech/substrate/blob/master/frame/im-online/src/lib.rs#L520-L540).

  • Hi @Andre, Thank you for pointing this out. This has helped.
    – Yeou
    Jul 28, 2022 at 7:33

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.