Upgrade to Pro — share decks privately, control downloads, hide ads and more …

neon-jsで始めるNEO dApps開発入門

657d1e8748276a2e99c8b68df8299c62?s=47 GENM
September 30, 2018

neon-jsで始めるNEO dApps開発入門

ブロックチェーンNEOの開発をするにあたって、有力な選択肢であるJavascript SDKのneon-jsについて紹介

657d1e8748276a2e99c8b68df8299c62?s=128

GENM

September 30, 2018
Tweet

Transcript

  1. neon-jsͰ࢝ΊΔdApps։ൃೖ໳ JS SDK for NEO blockchain

  2. NEO Keymakers Japan @genm ࣗݾ঺հ ࠓా େ੟(23) ܚጯٛक़େֶϝσΟΞσβΠϯݚڀՊ म࢜1೥ Taisei

    Imada ৯΂Δ௼Γ NEO Keymakers Japanॴଐ
 ࡢ೥·ͰΧ΢ϯηϦϯάϩϘοτͷ։ൃ
 ݱࡏ͸NEOΛத৺ʹϒϩοΫνΣʔϯͷษڧத ిࢠ޻࡞ Facebook: taisei_imada
  3. NEO Keymakers Japan @genm neon-js: NEO BlockchainͷͨΊͷJavascript SDK ΢ΥϨοτػೳ τϥϯβΫγϣϯ

    ͦͷଞศརػೳ neon-js ϥΠτ΢ΥϨοτΛ࡞੒͢Δͷʹे෼ͳػೳ
  4. NEO Keymakers Japan @genm ϥΠτ΢ΥϨοτͱϑϧϊʔυͷҧ͍ ϥΠτ΢ΥϨοτ ϑϧϊʔυ neo-python ඞཁͳ༰ྔ͕গͳ͍ͷͰεϚϗɺϒϥ΢βͰ࢖͍΍͍͢ neo-GUI

    neo-CLI ϥΠτ΢ΥϨοτ͸ɺϒϩοΫνΣʔϯͷσʔλΛ࣋ͨͳ͍ ϑϧϊʔυʹґଘ͢Δ୅ΘΓʹ༰ྔগɺػೳγϯϓϧ ϥΠτ΢ΥϨοτ͸ϑϧϊʔυΛհͯ͠ϒϩοΫνΣʔϯͱ΍ΓऔΓΛߦ͏ ϒϩοΫνΣʔϯ طଘϊʔυ
  5. NEO Keymakers Japan @genm Πϯετʔϧ npm i @cityofzion/neon-js <script src="https://unpkg.com/@cityofzion/neon-js"

    /> npm ϒϥ΢β(CDN)
  6. NEO Keymakers Japan @genm neon-js 4.0+ͷߏ଄ Core Module
 Plugin Module

    ɾAPI ɾNEP5 ɾWallet ɾTransactions ɾRPC ɾSmart Contract ɾUtility ɾConstants ɾSettings ɾLogging ϒϩοΫνΣʔϯͱͷ΍ΓऔΓʹඞཁͳجຊػೳ ֎෦Ϧιʔεʹґଘ͢Δิॿతͳ΋ͷ
  7. NEO Keymakers Japan @genm Core Modules Wallet: wallet import {

    wallet } from “@cityofzion/neon-js"; ϓϥΠϕʔτΩʔ͔Β΢ΥϨοτΛੜ੒ͯ͠෮߸Խ
 const c = new wallet.Account( ɹ“6PYLHmDf6AjF4AsVtosmxHuPYeuyJL3SLuw7J1U8i7HxKAnYNsp61HYRfF” ); // ҉߸Խ͞ΕͨΩʔɾΞυϨεͷදࣔ console.log(c.encrypted); // encrypted key console.log(c.address); // throws error // ύεϫʔυΛೖྗͯ͠΢ΥϨοτͷ෮߸Խ c.decrypt("city of zion"); console.log(c.address); // ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW
  8. NEO Keymakers Japan @genm Core Modules Transactions: tx // τϥϯβΫγϣϯͷੜ੒ͱγϦΞϥΠζ

    import { tx } from “@cityofzion/neon-js"; let tx = Neon.create.tx({ type: 128 }); const serializedTx = tx.serialize(); RPC: rpc // ΫΤϦΛ࡞੒ͯ͠ϊʔυʹ໋ྩΛૹ৴͢Δɻ import { rpc } from "@cityofzion/neon-js"; const client = new rpc.rpcClient(URL); let query = Neon.create.query({method: 'custommethod'} client.execute(query)
  9. NEO Keymakers Japan @genm Core Modules Smart Contract: sc Utility:

    u // εϚʔτίϯτϥΫτͷςετ(test invoke) import { sc, rpc } from “@cityofzion/neon-js"; const sb = new sc.scriptBuilder() sb.emitAppCall(scriptHash, operation, args[]) rpc.Query.invokeScript(sb.str).execute(nodeURL) // Invoke // จࣈྻΛHEXʹͨ͠ΓɺHEX͔Βจࣈྻʹͨ͠Γ import { u } from “@cityofzion/neon-js"; u.str2hexstring(“normalString”); //string→Hex u.hexstring2str("6e6f726d616c537472696e67"); // Hex→string
  10. NEO Keymakers Japan @genm Core Modules Constants: CONST Settings: settings

    Logging: logging // ఆ਺͕৭ʑೖ͍ͬͯΔ import { CONST } from “@cityofzion/neon-js"; const rpcVersion = CONST.RPC_VERSION // ωοτϫʔΫͷొ࿥ import Neon, { settings } from “@cityofzion/neon-js"; const newNet = new Neon.rpc.Network({ name: "NewNet" }); Neon.add.network(newNet); // ϩάͷઃఆ import { logging } from “@cityofzion/neon-js"; logging.logger.setAll('info')
  11. NEO Keymakers Japan @genm Plugin Module ֎෦APIαʔό(neoscan͋Δ͍͸neonDB)͕ແ͍ͱಈ͔ͳ͍ API NEP5 εϚʔτίϯτϥΫτ͕NEP5ͷن֨ʹͦͬͨߏ੒Λ͍ͯ͠Δඞཁ͕͋Δ

    // Balanceͷऔಘ import { api } from “@cityofzion/neon-js”; api.neoscan.getBalance("http://www.neoscan-testnet.io/test_net/v1/", address); // NEP5τʔΫϯͷ৘ใऔಘ api.nep5.getTokenInfo("http://seed1.neo.org:20332", rpxScriptHash);
  12. NEO Keymakers Japan @genm neon-jsΛ࢖ͬͨΞϓϦߏ੒ NEO Blockchain neoscan ΫϥΠΞϯτ PluginModuleܥͷૢ࡞


    InvokeɺBalanceͳͲ ϒϩοΫνΣʔϯͷૢ࡞ CoreModuleܥͷૢ࡞ WalletɺTransactionɺRPC
  13. NEO Keymakers Japan @genm neoscanͱ͸ NEO Blockchain neoscan ಉظ άϥϑΟΧϧͳWEBΞϓϦέʔγϣϯ෇͖ͷAPIαʔό

    શͯͷτϥϯβΫγϣϯཤྺ͔ΒͦΕͧΕͷΞΧ΢ϯτͷ࢒ߴΛࢉग़
  14. NEO Keymakers Japan @genm ϓϥΠϕʔτωοτͰָʹ։ൃ͢Δ https://github.com/keymakers/neo-scan-docker NEOSCAN DOCKER $ git

    clone https://github.com/keymakers/neo-scan-docker.git $ cd neo-scan-docker $ docker-compose up -d Private net neoscan DockerCompose
  15. NEO Keymakers Japan @genm ऴΘΓʹ neon-js͸ɺϒϥ΢β΍ElectronͰಈ͔͢
 dApps։ൃʹ͓͍ͯݱঢ়࠷΋༗ྗͳબ୒ࢶ

  16. NEO Keymakers Japan @genm ࢀߟࢿྉ 1. neon-js(Github)
 https://github.com/CityOfZion/neon-js 2. neon-js(Document)


    http://cityofzion.io/neon-js/ 3. neon wallet
 https://neonwallet.com/ 4. neoscan
 https://neoscan.io/ 5. neoscan docker
 https://github.com/slipo/neo-scan-docker