I use the following code to sign and send a transaction in my backend:

var txData = {
    nonce: nonceHex,
    gasPrice: gasPriceHex,
    gas: gasHex,
    data: contractData,
    from: ctx.mainAccount,

var tx = new EthTx(txData);
tx.sign(new Buffer(pKey, 'hex'));
var txHex = tx.serialize().toString('hex');

    .on('receipt', receipt => { ... }); 

Now what I'd like to do is instead of using the private key here, I'd like to use Metamask just to sign the transaction (and not send it)

Is it possible? In other words does Metamask has a way to do something similar to tx.sign(new Buffer(pKey, 'hex')); I'd like then my backend to send the signed transaction, not Metamask.

I tried to use web3.eth.personal like this:

var tx = new EthTx(txData);
var txHash = tx.hash();
var txUnsignedHex = txHash.toString('hex');

web3.personal.sign('0x' + txUnsignedHex, ethAccount, (err, result) => {  ... } );

But the result I get does not work when I run web3.eth.sendSignedTransaction

1 Answer 1


MetaMask does not currently support signing but not submitting a transaction, although the idea has been suggested before:


You could share your use case there, to help it gain priority.

Your Answer

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

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