1

I want to build a mobile app that will have a private key attached to it so that it can generate raw signed transactions.

I want to send these raw transactions to my server, which will then relay these transactions to a smart contract.

I am doing this because I am under the belief that the server will be the one to pay the gas fees for the transaction since it is the one who sends it to the ethereum network. Is this correct?

1

The private key which signs a transaction is subject to paying fees for the execution of that transaction on the network.

For instance from the Ethereum white paper,

The term "transaction" is used in Ethereum to refer to the signed data package that stores a message to be sent from an externally owned account.

and

  • a signature identifying the sender;
  • the amount of ether to transfer from the sender to the recipient;

From this information we know that the sender of a transaction is the externally owned account which signed it.

Furthermore the gas price which is more specific to your question,

Calculate the transaction fee as STARTGAS * GASPRICE, and determine the sending address from the signature. Subtract the fee from the sender's account balance and increment the sender's nonce. If there is not enough balance to spend, return an error.

This suggests that the gas is 'charged' to a sender of a transaction. Each full node who receives the transaction will ensure that it is well formed and update their internal state appropriately to reflect this change.

You'll need the server to sign the transaction with it's own key to allow them to pay the fees. A way around this could be by having the Ethereum user send the servers account enough ETH to cover the fees; then when the server accepts that this is valid, they can send the original tx to the network.

Hope this helps.

  • Thanks! I want to avoid charging the user any gas fees, however I want the transaction to be generated / signed by the user... is there a way to do this? I guess if I am creating the transaction from a central smart contract, all the gas would be paid by that smart contract and not the user? – bigpotato Nov 27 '17 at 17:35
  • I'm not too clear on who pays the gas. The mobile app doesn't necessarily have a smart contract, but it'll generate a transaction. But the transaction would be ran by the Smart contract. So who would pay for it..? – bigpotato Nov 27 '17 at 17:38
  • Yes, in that case you would be sending a message where the sender is the smart contract - which is implicit. If the reason you want to see if the user is who they say they are then you could just get them to sign a transaction and verify it is them from the server side. It's a design decision that is left up to you. Generally it will be the user who pays for the gas - which should be a very low amount. However if you have a sign up fee or something to your service you may want your server to act on their behalf and thus your server paying the fees. – Malone Nov 27 '17 at 17:39
  • Are transactions made from smart contracts, or can I create one without it? – bigpotato Nov 27 '17 at 18:34
  • In Ethereum, transactions that are sent from smart contracts are called messages - please see: github.com/ethereum/wiki/wiki/… You can create transactions from EOA's (externally owned accounts) which are not smart contracts, rather accounts generated outside of the network and generally controlled by humans. – Malone Nov 27 '17 at 18:47

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.