Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Droid on Chain - Berry Ventura Lev, Kik

95 views

Published on

As presented in Droidcon Tel Aviv 2017:
http://il.droidcon.com

Published in: Mobile
  • You can also find the slides here: https://docs.google.com/presentation/d/1SuVi-to25p5QwVQIVAIMRjfzQgSCTsKKi_-n1iKuE4o/edit#slide=id.p4
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Droid on Chain - Berry Ventura Lev, Kik

  1. 1. Droid On Chain An android journey into the ethereum blockchain berry@kik.comBerry Ventura Lev kin.kik.com
  2. 2. Kin Kin Foundation kin.kik.com A decentralized ecosystem of digital services for daily life
  3. 3. Working together
  4. 4. Agenda •Intro to Blockchain •Kin in Kik •Kin SDK how to •Kin SDK challenges
  5. 5. Intro to Blockchain
  6. 6. locks of transactions
  7. 7. P2P network locks of transactions
  8. 8. P2P network Decentralized Consensus locks of transactions
  9. 9. Ethereum in a nutshell • A multipurpose blockchain • Currency: Ether • Smart Contracts • Gas • DApp - Decentralized App
  10. 10. DApp Examples • KIN Wallet • Insurance • Music / Art • Travel Booking • Voting And many many more...
  11. 11. DApp Examples • KIN Wallet • Insurance • Music / Art • Travel Booking • Voting And many many more...
  12. 12. Ethereum Challenges • Scalability
  13. 13. Ethereum Challenges • Scalability • Confirmation time • Gas fees in ether • Difficult for users to adopt
  14. 14. Kin in Kik
  15. 15. Kin in Kik ● Selected Kik Power Users ● Created a wallet ● Awarded them with Kin
  16. 16. Kin in Kik ● View Balance ● Spend Experience ○ Stickers ● Earn Experiences ○ Polls ○ Upload stickers
  17. 17. Kin in Kik ● Advanced ● View public address ● Export account
  18. 18. Kin Android SDK Overview
  19. 19. Kin Android SDK 1. Create an account 2. Access account 3. Get Account balance 4. Transfer kin to address 5. Get Account Pending balance 6. Export account details It’s open source on github.com/kinfoundation/kin-sdk-core-android
  20. 20. Exploring Libraries Javascript • web3.js (github.com/ethereum/web3.js) Android • geth (github.com/ethereum/go-ethereum) • web3j (github.com/web3j/web3j)
  21. 21. Kin Android SDK 1. Create an account 2. Access account 3. Get Account balance 4. Transfer kin to address 5. Get Account Pending balance 6. Export account details It’s open source on github.com/kinfoundation/kin-sdk-core-android
  22. 22. KinClient ServiceProvider infuraProvider = new ServiceProvider(“https://ropsten.infura.io/TOKEN”, ServiceProvider.NETWORK_ID_ROPSTEN)); KinClient kinClient = new KinClient(context, infuraProvider); // Infura Registration: https://infura.io/register.html
  23. 23. 1. Create an account KinAccount account; try { if (!kinClient.hasAccount()) { account = kinClient.createAccount("aPassphrase"); } } catch (CreateAccountException e) { e.printStackTrace(); }
  24. 24. 2. Access account KinAccount account; if (kinClient.hasAccount()) { account = kinClient.getAccount(); } String address = kinAccount.getPublicAddress();
  25. 25. 3. Kin Balance Request<Balance> balanceRequest = account.getBalance(); balanceRequest.run(new ResultCallback<Balance>() { @Override public void onResult(Balance result) { Log.d("example", "The balance is: " + result.value(2)); } @Override public void onError(Exception e) { // Most likely OperationFailedException - check exception message } });
  26. 26. 4. Transfer Kin transactionRequest = account.sendTransaction(toAddress, passphrase, new BigDecimal("100")); transactionRequest.run(new ResultCallback<TransactionId>() { @Override public void onResult(TransactionId result) { Log.d("example", "The transaction id: " + result.toString()); } @Override public void onError(Exception e) { // could be OperationFailedException, PassphraseException } });
  27. 27. 5. Pending Balance Request<Balance> balanceRequest = account.getPendingBalance(); balanceRequest.run(new ResultCallback<Balance>() { @Override public void onResult(Balance result) { Log.d("example", "The pending balance is: " + result.value(2)); } @Override public void onError(Exception e) { // Most likely OperationFailedException - check exception message } });
  28. 28. 6. Export account try { String json = kinAccount.exportKeystore(“originalPass”, “newpass”); } catch (PassphraseException e) { e.printStackTrace(); }
  29. 29. { "address": "c136e3ca8510e126ed1785f8456c4918beb903", "crypto": { "cipher": "aes-128-ctr", "ciphertext":"63f85debdbc0d5b9467fc1cebd2d99038e40c3b03ca67c", "cipherparams": { "iv": "fd8cfc14c2f19eef580448d352424a37" }, "kdf": "scrypt", "kdfparams": { "dklen": 32, "n": 4096, "p": 6, "r": 8, "salt":"8cb2df621289db5882f385303f2dff71b26e1c1604b33b0f294206f7b" }, "mac":"cb0b2621ae6c7de219224b827a5a3d1f3ccc0fee8d10f01106b8c8eda68" }, "id": "884cc847-ae42-4491-815e-15768d6b8270", "version": 3 } Account Keystore JSON// this is a manually modified file to fit the screen. address & crypto don’t match
  30. 30. Hackathon!
  31. 31.
  32. 32. Kin SDK Challenges
  33. 33. Kin Balance Request<Balance> balanceRequest = account.getBalance(); balanceRequest.run(new ResultCallback<Balance>() { @Override public void onResult(Balance result) { Log.d("example", "The balance is: " + result.value(2)); } @Override public void onError(Exception e) { // Most likely OperationFailedException - check exception message } });
  34. 34. Kin Contract Address contractAddress = Geth.newAddressFromHex(“0xEB203DEa15fC49d0872C7614910C”); BoundContract boundContract = Geth.bindContract(contractAddress, KIN_CONTRACT_ABI, ethereumClient);
  35. 35. [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"c onstant":false,"inputs":[{"name":"_newOwnerCandidate","type":"address"}],"name":"requestOwnershipTransfer","outputs":[],"payable":false," stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint 256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true ,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":f alse,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","ou tputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimal s","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","typ e":"address"},{"name":"_value","type":"uint256"}],"name":"issueTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"fun ction"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256" }],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":fals e,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payabl e":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable": false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}]," name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs ":[],"name":"newOwnerCandidate","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constan t":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining" ,"type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type ":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{ "anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":f alse,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_by","type":"add ress"},{"indexed":true,"name":"_to","type":"address"}],"name":"OwnershipRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":t rue,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"}] Kin Smart Contract ABI// this IS the real kin contract abi
  36. 36. Dive in - getBalance Interface accountAddress = Geth.newInterface(); accountAddress.setAddress(account.getAddress()); Interfaces inputParams = Geth.newInterfaces(1); inputParams.set(0, accountAddress); Interface balanceResult = Geth.newInterface(); balanceInterface.setDefaultBigInt(); Interfaces results = Geth.newInterfaces(1); results.set(0, balanceResult); CallOpts callOpts = Geth.newCallOpts(); callOpts.setContext(gethContext); boundContract.call(callOpts, results, "balanceOf", inputParams);
  37. 37. Pending Balance • Challenge: Event log filtering on geth mobile library missing • Solution: Added... but still didn’t work!
  38. 38. Pending Balance • Challenge: Event log filtering on geth mobile library missing • Solution: Added... but still didn’t work! • Challenge: Bug in geth node implementation • Solution: Build our own parity node implementation cluster
  39. 39. Pending Balance • Challenge: Event log filtering on geth mobile library missing • Solution: Added... but still didn’t work! • Challenge: Bug in geth node implementation • Solution: Build our own parity node implementation cluster • Challenge: Inconsistent Balance • Solution: Enable cookies, so that same node is reused
  40. 40. Pending Balance • Challenge: Event log filtering on geth mobile library missing • Solution: Added... but still didn’t work! • Challenge: Bug in geth node implementation • Solution: Build our own parity node implementation cluster • Challenge: Inconsistent Balance • Solution: Enable cookies, so that same node is reused • Challenge: Still inconsistent balance with sticker shop • Solution: Using a single node, with a backup node ready if needed
  41. 41. To be continued... • Our journey is a bumpy one, but this is just the beginning • We are taking part in the greater effort of bringing blockchain to maturity and to mass adoption • Watch out our progress on our community channels Medium Contributors Reddit Telegram • Start playing with our SDK on testnet - see sample app • Remember that Kin Reward Engine is on its way !
  42. 42. Thank You! berry@kik.comBerry Ventura Lev kin.kik.com

×