How to create Ethereum accounts on iOS with the mobile Geth framework
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
// Get a path to save keystore files | |
let dataDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, | |
.userDomainMask, | |
true)[0] | |
let keyStorePath = dataDir + "/keystore" | |
print("keyStorePath: \(keyStorePath)") | |
// Get an instance which manages keystore files | |
let keyStoreManager = GethNewKeyStore(keyStorePath, GethLightScryptN, GethLightScryptP) | |
// Specify a password and create a new ethereum account | |
let account = try! keyStoreManager?.newAccount("password") | |
// Get an ethereum address in hex format | |
let address = account?.getAddress().getHex() | |
print("address: \(address!)") | |
// Get a path (URL) of the ethereum account | |
let url = account?.getURL() | |
print("url: \(url!)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment