This is one such link containing some examples of ink! contracts from parity's repo : https://github.com/paritytech/ink-examples/blob/main/rand-extension/lib.rs

Is there a way to call a custom function from a library, say a cryptographic library from the ink contract?

How to go about doing this?

I tried to add all the code I had from the library inside the ink! contract and it could work, but it is one heck of a tedious task and I don't think it is the correct way either.

1 Answer 1


Cryptographic libraries are usually really heavy in terms of size (and contacts should be smaller as possible). You can already checks here if the function you need is already implemented.

If not it should be implemented in the runtime and be called from the contract:

  • either add it to pallet-contracts (like it has been implemented for ECDSA crypto)
  • or via chain-extension calling an specific pallet (but it will depends on the L1)
  • 1
    L1 is parachain. Every parachain will have its own set of chain-extensions
    – P.Ossun
    Commented Feb 2, 2023 at 7:55

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.