I am building an application where I want to sign and send transaction through metamask prompt. Means as we sign and send transactions through web3 library in nodeJs so what will be the equivalent approach if I want to send that same transaction through metamask prompt.
1 Answer
Metamask is only available as a browser extension and mobile app. Your node js app won't run in the browser environment so it's not possible to connect to your browser metamask app with your node js app directly. What you can do is export your metamask private key to your environment variable and then use your node js app to send transactions to the blockchain with your metamask account. (I would advise doing so only if you are doing it on testnet if someone can get access to your private key of mainnet account they can steal all the assets associated with the account) Here's an example: Send Transaction with node js from your account example
Export private key from metamask: https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key