Polkadot & React Native

Ogous Chan Ali
1 min readFeb 14, 2023

--

Polkadot @polkadot/util-crypto library have known issues on using it with React Native. Util-crypto package is dependant on WASM bytes to be able to calculate cryptographic function more fast but also has a fallback library wasm-crypto-asmjs. It is vital and mandatory to be able to use sr25519 methods (they are only available via WASM); because Polkadot uses Schnorrkel/Ristretto x25519 (“sr25519”) as its key derivation and signing algorithm.

Polkadot docs clearly says: “*the fallback is fully tested and equivalent to the WASM version” s*ee source. And they point out a workaround here and here.

Pointed-out Workaround:

Using sr25519 methods from @polkadot/util-crypto and @polkadot/keyring works with react-native-crypto polyfill.

Other Workarounds:

  • Checked if there would be any Hermes solutions could be implemented. But turns out it is still not possible, but a work-in-progress topic among Hermes team. You could read more: https://github.com/facebook/hermes/issues/429 https://github.com/facebook/hermes/issues/395
  • There are many open source projects that uses Polkadot with React Native, they are handling absence of WASM with using WebView of React Native as a runner.
  • Solve it with native module, can work substrate

Open source React Native projects that implemented Polkadot interactions:

--

--