I managed to do this today after some painful debugging. The result is here: https://github.com/zupzup/react-native-ethereum-wallet
It's not a full example yet, but it shows how to interact with the running geth node.
Here's what I did:
First step, add the geth dependency to build.gradle:
compile 'org.ethereum:geth:1.6.7'
Then, in MainActivity.java, try to get the node running. You'll see if it's running correctly in the Android Monitor.
This looks something like this:
NodeConfig nc = new NodeConfig();
Node node = Geth.newNode(getFilesDir() + "/.eth1", nc);
Then, you need some way to expose this node to your Wrapping module. I just used a Singleton for this, but I guess there are cleaner ways to share state in Android.
Regarding the wrapping, I just used the official docs at https://facebook.github.io/react-native/docs/native-modules-android.html.
Basically, I created a method test
, which fetches the node
from the singleton
and executes something on it (in my case a simple getBalanceAt
query).
And this test
method can be called from React-Native with a callback, if you register the wrapping module correctly. Like this:
NativeModules.TestNative.test("tojavandback", (str) => {
Alert.alert(str);
})
This outputs, in my case, the amount of ether at the given address. It's just a simple example, but the whole end2end interaction works.
Hope this helps.