generated at
iOS で Ethereum のアカウント(アドレス)を作成
動作確認環境
Xcode 9.3
Geth 1.8.6

Geth フレームワークの導入
Geth は Ethereum の go による実装です。
今回は iOS 向けにビルドされた Geth を使用します。
Geth フレームワークの導入には、Cocoapods を使用します。
まだ、Podfile がない場合は、$ pod init で Podfile を作成します。
Podfile には次の行を追記します。
バージョンは適宜適切なものを使用してください。

Podfile
pod 'Geth', '1.8.6'

Podfile を更新したら、$ pod install で Geth フレームワークをインストールします。

Geth フレームワークの import
上記の手順が完了すると、 import Geth で Geth フレームワークをインポートできるようになります。

Ethereum アカウントの作成とアドレスの取得
次のコードで、Ethereum アカウントの作成とアドレスの取得ができます。

example.swift
// keystore ファイルを保存するディレクトリのパスを取得 let dataDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let keyStorePath = dataDir + "/keystore" print("keyStorePath: \(keyStorePath)") // keystore を管理してくれるやつのインスタンスを取得 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() print("url: \(url!)")

参考