npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-helios

v0.1.22

Published

A cross-platform trustless Ethereum light client for React Native.

Downloads

295

Readme

react-native-helios

⚠️ Currently react-native-helios only supports execution on iOS, MacOS, Android and Expo.

Throughout the majority of Ethereum's history, frontend applications have been forced to rely upon centralized interfaces like Infura to access the decentralized network. This is because to act as a meaningful participant to the network, such as an entity capable of submitting transactions or maintaining a verifiable history the network state, the protocol's current design demands high device specifications that are insurmountable for even top-end mobile devices.

This reliance on third party infrastructure typically aided the delivery of ethereum frontend applications, but is subject to the pitfalls of all centralized systems; susceptibility to downtime and subservience to censorship and monetization.

Introducing helios! 👋

Helios is an innovative new light client for Ethereum which is minimal enough to run on mobile devices or even from within React Native applications.

The key property enabled by helios, compared to traditional light clients, is the level of trustlessness.

Where contemporary light clients merely defer responsibility to a more powerful node, helios is capable of maintaining the state of the decentralized network autonomously by inferring the validity of the chain header by assessing the validity of the proof sequence that constitutes the canonical chain.

Much like the proposed design of the Portal Network, helios need only trust a potentially untrustworthy block header proof provider just once in order to quickly synchronize with canonical Ethereum chain, verify it's validity, and transact as an independent network participant.

❯ Learn more

react-native-helios ⚛️

react-native-helios is a React Native wrapper for helios:

yarn add react-native-helios

To instantiate a trustless JSON-RPC, we merely need to call the start() method:

import { start, StartParams } from 'react-native-helios';

const params: StartParams = {
  untrusted_rpc_url:
    'https://eth-mainnet.g.alchemy.com/v2/<your-alchemy-key>', // source of initial proofs
  consensus_rpc_url: 'https://www.lightclientdata.org',
};

const { shutdown } = await start(params);

console.log("Ready!");

// ...

await shutdown();

This will establish a JSON-RPC on your device running at http://127.0.0.1:8485, which can then be interacted like usual using ethers:

import { Platform } from 'react-native';
import { ethers } from 'ethers';
import { getHeliosProvider } from 'react-native-helios';

const provider = getHeliosProvider(params);

const [blockNumber, balance] = await Promise.all([
  provider.getBlockNumber(),
  provider.getBalance('cawfree.eth'),
]);

console.log(
  `Block number is: ${blockNumber} and balance is ${ethers.utils.formatEther(
    balance
  )}Ξ!`
);

You can also define a weak subjectivity checkpoint using the checkpoint parameter of StartParams. If you're unsure of a value to use, you can use: fallbackCheckpoint(network: Network):

import { fallbackCheckpoint, start } from 'react-native-helios';

const params: StartParams = {...};
const checkpoint = await fallbackCheckpoint(params);

await start({ ...params, checkpoint: fallbackCheckpoint });

Warning

If a checkpoint is not manually specified, the fallbackCheckpoint will be used. Please be aware of the potential dangers in the implicit trust assumptions of doing so.

Building from source 🏗

Note Currently, react-native-helios may only be compiled on Apple Silicon.

  1. Make sure you've installed rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Clone and build react-native-helios:
git clone https://github.com/cawfree/react-native-helios
cd react-native-helios
yarn ; yarn heliosup

For iOS, we leverage swift-bridge and cargo-lipo to automatically generate a Swift-compatible Native Module which bridges into the original Rust client. To support the arm64 architecture for both simulated and physical iOS devices, the target-specific static libraries are repackaged into an XCFramework.

For Android, we use flapigen and rifgen to synthesize a runtime-compatible interface. Currently, only the build architectures arm64_v8a and x86_64 are supported.

  1. Finally, run the Example Project.

Building with Expo 📲

  1. You can install to your project using npx expo install react-native-helios.
  2. Next, you'll need to add the Helios plugin to your Expo config (app.json, app.config.json or app.config.js):
{
  "expo": {
    "name": "my-app",
+   "plugins": [
+     "react-native-helios"
+   ]
  }
}
  1. Once that's done, use npx expo prebuild to generate Expo-friendly native binaries.
  2. Finally, run eas build to build a new binary, or use yarn ios or yarn android to start running.

Note: To run eas build, you'll need to npm install --global expo-cli eas-cli.

License ✌️

MIT