Use PEM file wallet
Code snippet was written on sdk-core v10.2.5
npm i @multiversx/sdk-core @multiversx/sdk-network-providers @multiversx/sdk-walletGet the UserSigner
import { UserSigner } from '@multiversx/sdk-wallet';
export const prepareUserSigner = (walletPemKey: string) => {
return UserSigner.fromPem(walletPemKey);
};export const getFileContents = (relativeFilePath: string, options: { isJSON?: boolean; noExitOnError?: boolean }) => {
const isJSON = options.isJSON === undefined ? true : options.isJSON;
const noExitOnError = options.noExitOnError === undefined ? false : options.noExitOnError;
const filePath = `${baseDir}/${relativeFilePath}`;
try {
accessSync(filePath);
} catch (err) {
if (!noExitOnError) {
console.error(`There is no ${relativeFilePath}!`);
exit(9);
} else {
return undefined;
}
}
const rawFile = readFileSync(filePath);
const fileString = rawFile.toString("utf8");
if (isJSON) {
return JSON.parse(fileString);
}
return fileString;
};Get the ApiNetworkProvider
Get the Account
Generate PEM file wallet
Derive PEM file
Last updated
Was this helpful?