| name | mvx-sdk-js-wallets |
| description | Wallet and key management for MultiversX TypeScript/JavaScript SDK. |
MultiversX SDK-JS Wallets & Signing
This skill covers account management, key derivation, and transaction signing.
Account Creation
import { Account, Address, Mnemonic, UserWallet, UserPem } from "@multiversx/sdk-core";
const account = await Account.newFromPem("wallet.pem");
const account = await Account.newFromKeystore("wallet.json", "password");
const account = entrypoint.createAccount();
Mnemonic Operations
const mnemonic = Mnemonic.generate();
const words = mnemonic.getWords();
const secretKey = mnemonic.deriveKey(0);
const publicKey = secretKey.generatePublicKey();
const address = publicKey.toAddress();
Wallet Storage
const wallet = UserWallet.fromMnemonic({
mnemonic: mnemonic.toString(),
password: "secure-password"
});
wallet.save("wallet.json");
const wallet = UserWallet.fromSecretKey({
secretKey: secretKey,
password: "secure-password"
});
wallet.save("wallet.json");
const pem = new UserPem(address.toBech32(), secretKey);
pem.save("wallet.pem");
Transaction Signing
const tx = await controller.createTransactionForTransfer(account, nonce, options);
const tx = await factory.createTransactionForTransfer(sender, options);
tx.nonce = account.getNonceThenIncrement();
tx.signature = await account.signTransaction(tx);
Message Signing
const message = new SignableMessage({ message: Buffer.from("Hello") });
const signature = await account.signMessage(message);
import { MessageSigner } from "@multiversx/sdk-core";
const isValid = MessageSigner.verify(message, signature, publicKey);
Ledger Device
import { LedgerAccount } from "@multiversx/sdk-hw-provider";
const ledger = new LedgerAccount();
await ledger.init();
const address = await ledger.getAddress(0);
Security Best Practices
| Practice | Reason |
|---|
| Use keystore files | Encrypted with password |
| Never commit PEM files | Plain text private keys |
| Use Ledger for mainnet | Hardware security |
| Validate addresses | Prevent typos |