Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to create Ethereum accounts on iOS with the mobile Geth framework
// 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
You can’t perform that action at this time.