Skip to content

Signing using EthersJS

Research

const { ethers } = require("ethers");

async function main(){
    var mnemonic_str = "test test test test test test test test test test test junk"
    var wallet = new ethers.Wallet.fromMnemonic(mnemonic_str)
    var message = "I Like Pie"
    var signedTransaction = await wallet.signMessage(message)
    var transaction = ethers.utils.verifyMessage(message, signedTransaction);
    console.log(`message             : ${message}`)
    console.log(`Wallet Address      : ${wallet.address}`)
    console.log(`Transaction Address : ${transaction}`)
}

main()