Skip to content
Discussion options

You must be logged in to vote

Let's say you have a private key as a string, you can do it like this:

// Create a private key instance for the Ed25519 scheme.
const privateKey = new Ed25519PrivateKey("0xdcaf65ead38f7cf0eb4f81961f8fc7f9b7f1e2f45e2d4a6da0dbef85f46f6057");
// Or for the Secp256k1 scheme
const privateKey = new Secp256k1PrivateKey("0xdcaf65ead38f7cf0eb4f81961f8fc7f9b7f1e2f45e2d4a6da0dbef85f46f6057");

// Create the account. Note, this only works for accounts that haven't had their authentication key rotated.
const account = await Account.fromPrivateKey({ privateKey });

If you aren't sure which scheme it is, you can use the following code:

const aptos = new Aptos();
const account = await aptos.deriveAccountF…

Replies: 1 comment

Comment options

banool
Mar 7, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by banool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ts-sdk Questions related to the TypeScript SDK
1 participant