0

iam just wondering. Are meta transactions not the same like raw transactions, which are signed by the user in frontend and send to a backend, where the transaction gets deployed?

3

Meta-transactions are different because if a user signs a transaction and forwards it to a meta-tx relay which broadcasts it to the network (sendRawTransaction()), the signer account would still be charged for gas computation, not the meta-tx relay.

The purpose of meta-transactions is to lower barrier adoption by enabling ether-less account to interact with smart contract. Basically another account acts as a relay to forward the transaction and bear the cost of the transaction fees (gas).

Example: An ether-less account account_x wants to send a transaction to a contract account_y (MyContract.myMethod()) via the meta-tx relay owner of a funded account_z.

i. account_x extracts the bytes-code from the smart contract transaction he wants to perform

var txdata = MyContract.myMethod().encodeABI();

ii. account_x signs with his private key the message sha3(txdata)

var signature = await web3.eth.personal.sign(message, account_x);

iii. account_x sends the following information to the relay

POST https://metatx-relay.net/sendtx
{
   "txdata": txdata,
   "from": account_x,
   "to": account_y,
   "msg": message,
   "signature": signature
}

iv. The relay backend gets the message and checks the signature

var accountRecovered = web3.eth.accounts.recover(req.body.message,req.body.signature)
if(accountRecovered == req.body.from) { // good to go }

v. The relay backend sends the transaction to MyContract (account_y) using it funded account account_z

web3.eth.sendTransaction({
    from: account_z,
    to: req.body.to,
    data: req.body.txdata
}).then(function(receipt){
    ...
});

Caveats: This is a very simplified flow !!!

  • No msg.sender possible

The transaction is sent and paid by the relay, so it's not possible to use the alias msg.sender in the smart contract to identify the original sender account_x.

  • The meta-tx relay is centralized and transaction requests could be censored

Building a network of relays with reward mechanism would be the way to go I believe where transaction request are randomly assigned to a relay.

See BouncerProxy contract

  • Whitelisted accounts.

Reference:

  • Thanks to Austin Griffith for his work: a working prototype of a meta-tx relay network with reward mechanism (economic incentive) and whitelisted addresses.
0

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.