What is Brethereum?
Brethereum is a Swift framework designed to make connecting to, and interacting with, the Ethereum network a breeze. It offers multiple off-the-shelf providers including, a local Geth LES node and Web3 RPC support via REST and WebSockets. It's heavily inspired by Swifthereum and the awesome work of Indisputable Labs.
How does it work?
Brethereum has two major halves, the first, an API that grants you access to the Ethereum network, and second, a local keystore that's managed by Geth to maintain a set of accounts on your behalf.
Brethereum lets you define a list of providers (in order of preference) that attempt to satisfy your requests. Currently the supported providers include...
- Local Geth LES node
- Infura WebSockets
- Infura REST RPC
- Any other REST RPC Provider
The default configuration used by Brethereum is...
- Geth LES
//the prefered decentralized method of communication, but takes time to sync and become available
- Infura WebSocket
//available within seconds of starting the app and provides realtime streaming updates
- Infura REST
//available instantly, reliable and requires very little resources
What this means is that when we call
suggestGasPrice(), Brethereum falls through the list of providers until it gets a valid response from one. This gives us the convenience of a purely remote Web3 interface (instant availability) and the decentralization of Geth's light client once it becomes available.
Brethereum also lets you constrain certain API calls to certain providers and/or certain classes of providers (
localOnly). This means that you can make sure resource intensive calls are handled by remote provides and calls that may handle sensitive data are only ever handled by your local node.
Brethereum aims to be provider agnostic, hopefully supporting a large array of different light client implementations as the community continues to develop new clients.
Right now Brethereum supports most of the major Web3 API calls. But it doesn't yet support things like Filter subscriptions, contract interactions, whisper, swarm, ENS resolving, etc...
Brethereum already has tests for all of the supported API calls including some keystore tests as well. These tests can run against each of the supported providers. This is a good start but it's far from comprehensive and many more tests are in the works so we can be confident that the framework works the way it's expected to without any hiccups.
Brethereum currently resides on a private GitLab repo but will be moved to a public repository and open sourced in the near future. When that happens, this page will be updated with a link to the new repository.