Skip to content

Instantly share code, notes, and snippets.

@hm0429
Created April 30, 2018 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hm0429/5ea09b7cf10feaeeba1b81048d139116 to your computer and use it in GitHub Desktop.
Save hm0429/5ea09b7cf10feaeeba1b81048d139116 to your computer and use it in GitHub Desktop.
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