How to sign tx with privatekey instead of mnemonic

I write a simple pancakeswap bot and i need to sign the tx, but the tutorials are only for signing with mnemonic, which i dont want to use.
My code is this:

//const mnemonic = ‘your mnemonic here, to send’;

const privateKey = ‘privateky goes here’

const provider = new ethers.providers.WebSocketProvider(’’);

const wallet = new Wallet(walletMnemonic.privateKey);

//const walletPrivateKey =

//walletMnemonic.address === walletPrivateKey.address

const account = wallet.connect(provider);

Hm haven’t done it, better check with Ethers community, please let us know if you get an answer from them

1 Like