Skip to content

Instantly share code, notes, and snippets.

@hm0429
Created April 30, 2018 06:17
Embed
What would you like to do?
iOS で Ethereum のアカウントを作成
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