[Ethereum] How to create wallet with web3j and web3swift like with web3js web3.eth.accounts.create(); function

iosweb3jweb3js

With web3js v1.0.0 you can create accounts with web3.eth.accounts.create(); and access the public address and private key with newWallet.address and newWallet.privateKey.

How can you do this with web3j or web3Swift.

The documentation is difficult to find this in.

Thanks for any help.

Best Answer

Here we go, by using web3swift library:

Create Account

    // Create keystore and account with password.    
    let keystore = try! EthereumKeystoreV3(password: "changeme"); // generates a private key internally if node "privateKey" parameter supplied
    let account = keystore!.addresses![0]
    print(account)

We are also working on unification of the API format. I already open issue to cover your need in the quesiton: https://github.com/matterinc/web3swift/issues/40

Here a usage example for the next major update of the library:

newWallet = web3.eth.accounts.create() 
// access the public address 
newWallet.address
//private key:
newWallet.privateKey
Related Topic