2

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.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
JustinZ
  • 183
  • 7

3 Answers3

1

Implement gas station network, paymaster will pay gas fees for sender user. You can implement gas station network on any chain.

naveen
  • 11
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Oct 27 '21 at 15:05
0

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.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
  • 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: https://ethereum.stackexchange.com/questions/3386/create-and-sign-offline-raw-transactions – Rob Hitchens Feb 11 '19 at 17:18
-2

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.

Igor Marcos
  • 99
  • 1
  • 2
  • 6
  • 1
    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