0

I want to send a request for signing a message on MetaMask. the method i assumed should do it is the signer.SignMessage(msg) however this is returning the signature without asking for approval on MetaMask.

const contract = require( "../artifacts/contracts/token.sol/token.json" );
const keys = require( "../keys.json" );

const alchemyProvider = new ethers.providers.AlchemyProvider( network = "ropsten", keys.ALCHEMY_API_KEY );
const signer = new ethers.Wallet( keys.ROPSTEN_PRIVATE_KEY, alchemyProvider );
const token = new ethers.Contract( keys.TOKEN_ADDRESS, contract.abi, signer );

async function main ()
{

    msg = "Hallo Welt";
    let signature = await signer.signMessage( msg );
    console.log( signature );
}
main();

the console is returning the signature hash already. Should I use a different Method?

2

1 Answer 1

1

The private key is hardcoded so it does not need metamask's approval even if you connect your wallet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.