Can't seem to find the right function to ask the user to sign a transaction via metamask, this is my code so far:
const bet = '102500000000000010'
const account = '0xc8133b744147078a551b8d9c547414d427d8f579'
web3.eth.getTransactionCount(account, function (err, nonce) {
const data = Contract.methods.payBet(1553399554260556, bet).encodeABI();
const tx = new Tx({
nonce,
gasPrice: 165335,
gasLimit: 100000,
to: "0x232b....",
value: bet,
data,
})
//THIS tx.sign SHOULD BE THE METAMASK PART, since I dont have the user PK
tx.sign(ethereumjs.Buffer.Buffer.from(privateKey, 'hex'));
var raw = '0x' + tx.serialize().toString('hex');
web3.eth.sendSignedTransaction(raw, function (err, transactionHash) {
console.log(transactionHash);
});
});
What should I do to ask the user to sign the tx? I also tried to use web3.eth.sendTransaction but it is not supported by infura.
I'm abit lost here