Created
April 30, 2018 06:17
-
-
Save hm0429/7f34c1e4839ac3f7a40dc3f09a0a0eaf to your computer and use it in GitHub Desktop.
iOS で Ethereum のアカウントを作成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Geth | |
// keystore ファイルを保存するディレクトリのパスを取得 | |
let dataDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, | |
.userDomainMask, | |
true)[0] | |
let keyStorePath = dataDir + "/keystore" | |
print("keyStorePath: \(keyStorePath)") | |
// keystore を管理してくれるやつのインスタンスを取得 | |
// keyStoreManager のほうが適切な名前ではないかな? | |
let keyStoreManager = GethNewKeyStore(keyStorePath, GethLightScryptN, GethLightScryptP) | |
// パスワードを指定してアカウントを作成 | |
let account = try! keyStoreManager?.newAccount("password") | |
// 16進数表記のアカウントのアドレスを取得 | |
let address = account?.getAddress().getHex() | |
print("address: \(address!)") | |
// keystore ファイルの URL (パス) を表示 | |
let url = account?.getURL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment