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
MDN Web Docs に日本語翻訳でコントリビュートしたくなる
ohmori_yusuke
1
130
型で語るカタ
irof
0
700
AI Agent 時代のソフトウェア開発を支える AWS Cloud Development Kit (CDK)
konokenj
6
800
DMMを支える決済基盤の技術的負債にどう立ち向かうか / Addressing Technical Debt in Payment Infrastructure
yoshiyoshifujii
3
410
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
300
ソフトウェア品質を数字で捉える技術。事業成長を支えるシステム品質の マネジメント
takuya542
2
15k
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
870
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.5k
Porting a visionOS App to Android XR
akkeylab
0
680
Goで作る、開発・CI環境
sin392
0
260
AWS Summit Japan 2024と2025の比較/はじめてのKiro、今あなたは岐路に立つ
satoshi256kbyte
0
120
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
250
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
970
We Have a Design System, Now What?
morganepeng
53
7.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
830
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Become a Pro
speakerdeck
PRO
29
5.4k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
BBQ
matthewcrist
89
9.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.2k
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!!