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
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
510
Agentic Coding: The Future of Software Development with Agents
mitsuhiko
0
100
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
猫と暮らす Google Nest Cam生活🐈 / WebRTC with Google Nest Cam
yutailang0119
0
120
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
270
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.3k
AIともっと楽するE2Eテスト
myohei
6
2.6k
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
150
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
12
4.5k
Rails Frontend Evolution: It Was a Setup All Along
skryukov
0
140
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
250
Featured
See All Featured
Six Lessons from altMBA
skipperchong
28
3.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Raft: Consensus for Rubyists
vanstee
140
7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
54k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Building Applications with DynamoDB
mza
95
6.5k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Gamification - CAS2011
davidbonilla
81
5.4k
How GitHub (no longer) Works
holman
314
140k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
300
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!!