1

I am kind of new to web3js. I am not sure which functions should I use and which is the correct flow to achieve this. I don't have the user's private keys and I need to send a transaction (filling the data field with a certificate's hash) from their account. So, Metamask (or similar addons) are necessary. I can't use eth.sendTransaction cause I dont have the private key. I should use 'eth.sendSignedTransaction' but, how do I get the private key from Metamask to sign it? can I delegate the signing to Metamask?

Edit

When I use the eth.sendTransaction method on Infura, I get the error:

The method eth_sendTransaction does not exist/is not available

  • When using eth.sendTransaction with Metamask a popup will appear and ask the user if they want to confirm the transaction. The private key is not needed. – Ismael Mar 23 '21 at 01:39
  • @Ismael sending a transaction to an Infura api will not let me use sendTransaction returns error method eth_sendTransaction does not exist/is not available – Alejandro Veintimilla Mar 23 '21 at 18:09
  • Infura doesn't support sendTransaction you have to use something else to sign transaction on your behalf, like Metamask or HDWalletProvider. See here how to use it https://ethereum.stackexchange.com/a/46002/. – Ismael Mar 23 '21 at 18:24
  • @Ismael but then, how can I get that private key? can I delegate the signing to Metamask? – Alejandro Veintimilla Mar 23 '21 at 18:34
  • To use Metamask you have to connect to its provider, see here https://docs.metamask.io/guide/getting-started.html. Metamask doesn't allow access to the private key (it may not have it if you use a hardware wallet for example). – Ismael Mar 23 '21 at 18:41
  • @Ismael yea .. so I am not sure how to sign a transaction and send it to Infura through Metamask, delegating the signing... (which eth.function, etc). – Alejandro Veintimilla Mar 23 '21 at 18:49
  • When you use Metamask you don't have to deal with Infura directly, you will be using Metamask connection. If you want to use Infura directly then you cannot use Metamask, you have to use a wallet provider like HDWalletProvider. – Ismael Mar 23 '21 at 19:12

0 Answers0