Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
IOST ハンズオン
Search
YutaSugimura
September 01, 2019
Programming
0
330
IOST ハンズオン
YutaSugimura
September 01, 2019
Tweet
Share
More Decks by YutaSugimura
See All by YutaSugimura
Uniswapについて調べてみた
yutasugimura
0
400
Other Decks in Programming
See All in Programming
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
780
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
150
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
190
20250704_教育事業におけるアジャイルなデータ基盤構築
hanon52_
5
790
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
420
XP, Testing and ninja testing
m_seki
3
250
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
360
初学者でも今すぐできる、Claude Codeの生産性を10倍上げるTips
s4yuba
16
11k
Hack Claude Code with Claude Code
choplin
4
2.1k
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
120
dbt民主化とLLMによる開発ブースト ~ AI Readyな分析サイクルを目指して ~
yoshyum
3
1k
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
760
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
The Power of CSS Pseudo Elements
geoffreycrofte
77
5.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
4 Signs Your Business is Dying
shpigford
184
22k
Statistics for Hackers
jakevdp
799
220k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
54k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Speed Design
sergeychernyshev
32
1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Transcript
javaScriptでブロックチェーンを学ぶ!名古屋編
IOSTでスマートコントラクトを作成する
iGasͱIRam iGas: トランザクションの時に発⽣する⼿数料 iRam: ブロックチェーンに書き込む際に必要な⼿数料 購⼊することで取得可能。 余った分のiRamは売ったり送ったりすることが可能 IOSTをdepositすることで取得することが可能
テストネットのアカウントを作成する アカウントの作成 https://testnet.explorer.iost.io/applyIOST Generate KeyPair for meをクリックして Account PubKeyを発⾏する
アカウントの作成 完了するとPrivateKeyが表⽰される Private Keyをコピーしてどこかにメモしておく *紛失すると2度と復元することはできません
https://chrome.google.com/webstore/detail/iwallet/kncchdigobghenbbaddojjnnaogfppfj iWalletのインストール chromeに追加する
iWalletのアカウント作成 chromeの右上に アイコンが表⽰されているのでクリックして 起動する passwordの⼊⼒し、 Import Accountをクリック
アカウント追加 先ほど作成した アカウントのPrivateKeyを貼り付け Submitをクリックする
アカウント確認 アカウントが正常にimportできているか確認する これでアカウント作成は完了
IDEについて
IDE https://chainide.com/ 今回はIDEを使ってコントラクトの作成、実⾏を⾏う ChainIDEを使⽤
IDE デフォルトが中国語. 設定から英語に変換可能 もともと3つの異なるコントラクトが⽤意されているので、 簡単に試すことが可能 iwalletのアカウントと連携しているため、簡単にデプロイ、実⾏が可能
IDE β版のため不具合が多いので気をつけることが多い ・ウォレットを起動した状態で、IDEを開く, 開いたらアカウントを変更しない ・更新すると書き込んだコードが消えることがある ・compileし直しても更新されない ・ページ更新するとデプロイしたコードが消える
iRamの準備1 アカウントインポート後,iRamを購⼊していく コントラクトのデプロイ時、 ブロックチェーンにデータを保存するため必要 Purchase Amountに購⼊する⾦額を指定する
iRamの準備2 Submitクリックするとこの画⾯になる SuccessfullyなればOK
今回はIRC20tokenを作成する
トークンについて IOSTではFungible Tokenを作成するための規格が⽤意されている https://developers.iost.io/docs/en/3-smart-contract/Token.html 今回は最低限の機能のみで作成 create, issue, transfer, balanceOf, supply,
totalSupply のみ使⽤ Iost.tokenのインターフェース Iost.tokenという組み込みシステムコントラクトを使⽤
実際にトークンを作成する
New file 左上のプラスマークをクリックしてtokenというファイルを作成 新規ファイルの作成
Contract1 name: トークンのシンボル fullName: トークンの名前 decimal: 少数点以下の桁数 totalSupply: 最⼤発⾏枚数 admin:
このコントラクトのオーナー(先ほど作ったアカウント名) お好きな設定に変更する (a-z, 0-9, _)のみ
Contract2 Class, init関数の作成 1. Tokenというクラスを作成する 初期デプロイ時に実⾏される関数 それ以降は実⾏されない 2. initという関数を作成する
Contract3 トークンの作成 IOST Blockchain API https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html init内部にデプロイ時に 実⾏される関数を書いていく IRC20にあったcreateを使って トークンを作成する
Blockchain.callWithAuth(“token.iost”, “create”, [args]) create(tokenSymbol, issuer, totalSupply, configJson) // string, string, number, json blockchainは元々⽤意されているAPI 詳しくは⬇ ೝূΛ͏Ҿ͖ͰίϯτϥΫτΛݺͼग़͠
Contract4 トークンの発⾏する関数作成 1. ⼆つの内部関数を作成する _amount:扱うトークンの量を計算する関数 _checkToken: トークンのシンボルがあっているか確認する関数
Contract5 _checkToken, _amountを使⽤ トークンの発⾏する関数作成 2. blockchain.callWithAuthを使ってissueを実⾏ issue(tokenSymbol, to, amountStr) //string,
string, string https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html IOST Blockchain API: https://developers.iost.io/docs/en/3-smart-contract/Token.html IRC20:
Contract6 _checkToken, _amount 送⾦を⾏う為の関数作成 blockchain.callWithAuthを使ってtransferを実⾏ transfer(tokenSymbol, from, to, amountStr, memo)
//string, string, string, string, string https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html IOST Blockchain API: https://developers.iost.io/docs/en/3-smart-contract/Token.html IRC20:
Contract7 _call関数を作成
Contract8 _call, _checkTokenを使⽤ 残⾼確認する関数を作成 IRC20 balanceOf balanceOf(tokenSymbol, from) //string, string
https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html IOST Blockchain API: https://developers.iost.io/docs/en/3-smart-contract/Token.html IRC20:
Contract9 _call, _checkTokenを使⽤ 現在の発⾏量を確認する関数を作成 IRC20 supply supply(tokenSymbol) //string https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html IOST
Blockchain API: https://developers.iost.io/docs/en/3-smart-contract/Token.html IRC20:
Contract10 https://developers.iost.io/docs/en/3-smart-contract/IOST-Blockchain-API.html IOST Blockchain API: _call, _checkTokenを使⽤ 最⼤発⾏数を確認する関数の作成 IRC20 totalSupply
totalSupply(tokenSymbol) //string https://developers.iost.io/docs/en/3-smart-contract/Token.html IRC20:
Contract11 Tokenをエクスポート これでコントラクト完成
Deploy1 token.jsをコンパイルしてABIを作成する コンパイルが成功するとfunctionが表⽰される
Deploy2 token.jsとtoken.js.abiを選択して デプロイする Gas RatioとGas Limitはこのままで確定をクリック
Deploy3 デプロイが成功すると 失敗する場合はnameが被っている可能性がほとんど 今回の設定
Deploy4 成功するとフォームが出現する 今回はこれを使って実際にコントラクトを動かしていく
function1 現在の残⾼を確認する balanceOfを選択 実⾏をクリック 引数1: トークンのシンボル(name) 引数2: 確認するアカウント 現在0であることを確認
function2 トークンを発⾏する Issueを選択 実⾏をクリック 引数1: トークンのシンボル(name) 引数2: 付与するアカウント succeededならOK 引数3:
発⾏枚数
function3 再度残⾼確認 発⾏枚数が追加されていればOK
iwallet1 Add Tokenをクリック トークン名を⼊⼒してAddをクリック iwalletから残⾼確認や送⾦可能 iwalletにトークンをインポート
Happy Hacking!!