Skip to Content
Supra Layer 1MoveVMTypeScript SDKGuidesCreate Supra Accounts

Create Supra Accounts

How to create new and import existing accounts.

SupraAccount class constructor

new SupraAccount() new SupraAccount(Buffer.from('YOUR_PRIVATE_KEY', 'hex'))

Create a new supra account or create one from the provided private key.
If no privateKeyBytes parameter is provided, a new account will be generated.

Parameters

NameTypeOptional
privateKeyBytesUint8Array
addressMaybeHexString

Returns SupraAccount 


fromDerivePath function

Create a new SupraAccount from mnemonic.

SupraAccount.fromDerivePath(path, mnemonic)

Parameters

NameTypeOptional
pathstring
mnemonicsstring

Returns SupraAccount 


Example

The SupraAccount class allows you to generate new accounts, import private key, or derive from mnemonics.

Initialize a new project

npm init && npm add -D typescript @types/node ts-node && npx tsc --init

Install Supra’s TypeScript SDK

npm install supra-l1-sdk

Create supra_account_example.ts and import dependencies


supra_account_example.ts

typescript import {SupraAccount} from 'supra-l1-sdk';

Generate a new account

const newAccount = new SupraAccount()

Generate an account from private key

const accountFromPk = new SupraAccount(Buffer.from('YOUR_PRIVATE_KEY', 'hex'))

Generate an account from mnemonics

const path = "m/44'/637'/0'/0'/0'" const mnemonic = '' const accountFromMnemonics = SupraAccount.fromDerivePath(path, mnemonic)

Complete code


supra_account_example.ts
import { SupraAccount } from 'supra-l1-sdk' async function main() { const newAccount = new SupraAccount() console.log('newAccount: ', newAccount.address()) const accountFromPk = new SupraAccount(Buffer.from('YOUR_PRIVATE_KEY', 'hex')) console.log('accountFromPk Address: ', accountFromPk.address()) const path = "m/44'/637'/0'/0'/0'" const mnemonic = '' const accountFromMnemonics = SupraAccount.fromDerivePath(path, mnemonic) console.log('accountFromMnemonics: ', accountFromMnemonics.address()) } main()

Execute code npx ts-node supra_account_example.ts

Last updated on