-
Notifications
You must be signed in to change notification settings - Fork 20.2k
Mobile: Introduction
The Ethereum blockchain along with its two extension protocols Whisper and Swarm was originally conceptualized to become the supporting pillar of web3, providing the consensus, messaging and storage backbone for a new generation of distributed (actually, decentralized) applications called DApps.
The first incarnation towards this dream of web3 was a command line client providing an RPC interface into the peer-to-peer protocols. The client was soon enough extended with a web-browser-like graphical user interface, permitting developers to write DApps based on the tried and proven HTML/CSS/JS technologies.
As many DApps have more complex requirements than what a browser environment can handle, it became apparent that providing programmatic access to the web3 pillars would open the door towards a new class of applications. As such, the second incarnation of the web3 dream is to open up all our technologies for other projects as reusable components.
Starting with the 1.5 release family of go-ethereum
, we transitioned away from providing only a full blown Ethereum client and started shipping official Go packages that could be embedded into third party desktop and server applications. It took only a small leap from here to begin porting our code to mobile platforms.
Similarly to our reusable Go libraries, the mobile wrappers also focus on four main usage areas:
- Simplified client side account management
- Remote node interfacing via different transports
- Contract interactions through auto-generated bindings
- In-process Ethereum, Whisper and Swarm peer-to-peer node
You can watch a quick overview about these in Peter's (@karalabe) talk titled "Import Geth: Ethereum from Go and beyond", presented at the Ethereum Devcon2 developer conference in September, 2016 (Shanghai). Slides are available here.
The go-ethereum
mobile library is distributed either as an Android .aar
archive (containing binaries for arm-7
, arm64
, x86
and x64
); or as an iOS XCode framework (containing binaries for arm-7
, arm64
and x86
). We do not provide library bundles for Windows phone the moment.
The simplest way to use go-ethereum
in your Android project is through a Maven dependency. We provide bundles of all our stable releases (starting from v1.5.0) through Maven Central, and also provide the latest develop bundle through the Sonatype OSS repository.
To add an Android dependency to the stable library release of go-ethereum
, you'll need to ensure that the Maven Central repository is enabled in your Android project, and that the go-ethereum
code is listed as a required dependency of your application. You can do both of these by editing the build.gradle
script in your Android app's folder:
repositories {
mavenCentral()
}
dependencies {
// All your previous dependencies
compile 'org.ethereum:geth:1.5.2' // Change the version to the latest release
}
To add an Android dependency to the current develop version of go-ethereum
, you'll need to ensure that the Sonatype snapshot repository is enabled in your Android project, and that the go-ethereum
code is listed as a required SNAPSHOT
dependency of your application. You can do both of these by editing the build.gradle
script in your Android app's folder:
repositories {
maven {
url "https://oss.sonatype.org/content/groups/public"
}
}
dependencies {
// All your previous dependencies
compile 'org.ethereum:geth:1.5.3-SNAPSHOT' // Change the version to the latest release
}
If you prefer not to depend on Maven Central or Sonatype; or would like to access an older develop build not available any more as an online dependency, you can download any bundle directly from our website and insert it into your project in Android Studio via File -> New -> New module... -> Import .JAR/.AAR Package
.
You will also need to configure gradle
to link the mobile library bundle to your application. This can be done by adding a new entry to the dependencies
section of your build.gradle
script, pointing it to the module you just added (named geth
by default).
dependencies {
// All your previous dependencies
compile project(':geth')
}
The simplest way to use go-ethereum
in your iOS project is through a CocoaPods dependency. We provide bundles of all our stable releases (starting from v1.5.3) and also latest develop versions.
To add an iOS dependency to the current stable or latest develop version of go-ethereum
, you'll need to ensure that your iOS XCode project is configured to use CocoaPods. Detailing that is out of scope in this document, but you can find a guide in the upstream Using CocoaPods page. Afterwards you can edit your Podfile
to list go-ethereum
as a dependency:
target 'MyApp' do
# All your previous dependencies
pod 'Geth', '1.5.3' # Change the version to the latest release
end
Alternatively, if you'd like to use the latest develop version, replace the package name Geth
with GethDevelop
and potentially also set a dynamic version number (e.g. '~> 1.5'
) to always switch to the latest bundle in that release family.
If you prefer not to depend on CocoaPods; or would like to access an older develop build not available any more as an online dependency, you can download any bundle directly from our website and insert it into your project in XCode via Project Settings -> Build Phases -> Link Binary With Libraries
.
Do not forget to extract the framework from the compressed .tar.gz
archive. You can do that either using a GUI tool or from the command line via (replace the archive with your downloaded file):
tar -zxvf geth-ios-all-1.5.3-unstable-e05d35e6.tar.gz