Is it possible to send private key signed transactions directly from the contract? The thing I want to do is to create a similar function

function sendTransactionForUser(_signedData, contractAddress){ sendSignedTrx(contractAddress, signedData) }

the main point is that the user would sign data -> send it to the owner -> owner would send transaction on behalf of the user, and pay gas for the user.


Your title and description mix up some important concepts.

In Ethereum, all activity starts with a transaction signed by an externally owned account. A contract has no known private key and cannot sign a transaction.

But, you don't want the contract to sign. You want the original sender to sign and pass the siged transaction to someone else (you said, the owner).

Good news. If the sender signs the transaction, then anyone can relay it.

Hope it helps.

  • Hello and thank you for the answer. I have a few questions. How can I sign the data using web3? Will the signed data be a type string? How would that transaction in a contract look like? – JustinZ Feb 11 '19 at 17:13
  • This might help you get started: ethereum.stackexchange.com/questions/3386/… – Rob Hitchens Feb 11 '19 at 17:18

In short, yes, you can, but why would you sign with a contract? You would need to give your private key to it, and anyone would be able to see it.

  • I don't want it to sign with a contract. I want to pass in already signed data and send transactions on behalf of a user – JustinZ Feb 12 '19 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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