How can I import an account created from Sui wallet to SUI CLI? @amnn
The process is not straightforward today, but it is possible, and it’s on our radar to make this better!
Here’s how you export your private key from “Sui Wallet”:
- Unlock your wallet
- Hit the hamburger (three line) menu, top right
- Click “Accounts”
- Expand the account you want to import
- Click “Export Private Key”
- Enter your wallet password to confirm
- Hit “Copy”
At this point a modal should pop up saying “Private key copied”. This will be a 32 byte hexadecimal number (64 hexadecimal digits and a leading “0x” to make 66 characters total). We need to change the format of it slightly to import it into the CLI, which can be done as follows on a recent (1.0.0+) version of the CLI:
$ sui keytool convert <wallet-private-key>
2023-06-08T08:59:55.399769Z INFO sui::keytool: Keystore formatted private key: "<cli-private-key>"
Take the <cli-private-key>
(with quotes) and add it to the end of the JSON array written to ~/.sui/sui_config/sui.keystore
.
NOTE: Don’t add a trailing comma when you do this, JSON does not support that.
Confirm that your wallet address shows up when you do:
$ sui client addresses
Pick it as the active address using:
$ sui client switch --address <address>
And then double check using sui client active-address
that it is active.