Posted on c/ElrondDevelopers 1 ale316776319c/ElrondDevelopers 2 years ago does someone have a simple js script to sign a transaction with PEM file and send it? Comment 1 Comments jul8221856699 2years ago import { parseUserKey, UserSigner } from '@elrondnetwork/erdjs-walletcore'; (...) export const prepareUserAccount = async (walletPemContents: string) => { const userKey = parseUserKey(walletPemContents); const address = userKey.generatePublicKey().toAddress(); return new Account(address); }; export const prepareUserSigner = (walletPemContents: string) => { return UserSigner.fromPem(walletPemContents); }; (...) const signer = prepareUserSigner(walletPemContents); (...) signer.sign(tx); await provider.sendTransaction(tx); const watcher = new TransactionWatcher(provider); const transactionOnNetwork = await watcher.awaitCompleted(tx); You can extract interesting parts of the code from here: https://github.com/ElvenTools/elven-tools-cli
import { parseUserKey, UserSigner } from '@elrondnetwork/erdjs-walletcore'; (...) export const prepareUserAccount = async (walletPemContents: string) => { const userKey = parseUserKey(walletPemContents); const address = userKey.generatePublicKey().toAddress(); return new Account(address); }; export const prepareUserSigner = (walletPemContents: string) => { return UserSigner.fromPem(walletPemContents); }; (...) const signer = prepareUserSigner(walletPemContents); (...) signer.sign(tx); await provider.sendTransaction(tx); const watcher = new TransactionWatcher(provider); const transactionOnNetwork = await watcher.awaitCompleted(tx); You can extract interesting parts of the code from here: https://github.com/ElvenTools/elven-tools-cli