question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meta transaction (a.k.a. Gasless transactions) using ethers.js

See original GitHub issue

Is there a way to implement a meta transaction using ethers.js library.

Consider a transaction to transfer 100 tokens from 0xAccountA to 0xAccountB. The transaction will be signed by 0xAccountA but the gas would be payed by some other 0xAccountC.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
joeb000commented, Mar 2, 2020

@ricmoo just FYI I am working on extending ethers.js to add an intuitive way for Dapp devs to integrate meta transactions into their dapp with only a couple lines of code.

I am imagining something like this:

    const metaConfig = {
        relayerURL: "https://somerelayernode.com",
        metaType: "erc1776" // metamask Generalized MetaTransaction Contest winner: https://github.com/wighawag/singleton-1776-meta-transaction
    }
    const metaSigner = provider.getMetaSigner(metaConfig)
    const metaContract = new ethers.MetaContract(address, abi, metaSigner)

    // call it just like you would with a normal ethers contract
    let metaTx = await metaContract.someFunction(param1, param2)

Basically allow dapp devs using ethers to set their relayer and metaType in a config object and initialize a MetaSigner (extension of Signer) which instead of signing a transaction and POSTing to the Provider’s URL, it will sign a meta transaction (in the above example with signTypedData_v4) and send the signed meta transaction hex string to the relayerURL.

To pilot this concept I extended ethers.js with my own meta-ethers library and used my own simplified meta transaction schema. My experiments have gone very well, so I am now working on forking ethers.js base code to build this functionality into the native ethers.js source code itself. Will post back here when I have anything worthy of review/beta testing.

2reactions
ricmoocommented, Oct 3, 2019

I have not actually used Meta-transactions yet, but all the necessary functions should certainly be available. I will be bugging the metatx cartel during DevCon5 to get caught up on the latest techniques. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create gasless-transactions/meta ...
Lets initiate a contract: const abi = ['function transferFrom(address sender, address recipient, uint256 amount)']; const payer = new ethers.
Read more >
How to create gasless-transactions/meta- ...
Consider a transaction to transfer 100 ERC20-tokens using a ERC20-contract from 0xAccountA to 0xAccountB . The transaction will be signed by ...
Read more >
How to do Gasless Transactions on Ethereum
If you use Ethereum, you are most likely familiar with gas. However, in this article, we go through how to do gasless transactions...
Read more >
How to re-send a transaction with higher gas price using ...
1. Sometimes, you submit a transaction on Ethereum without enough gas due to network congestion or too m... 2. We do a transaction...
Read more >
ethers.js - A Complete, Simple and Tiny Ethereum Library in ...
Transaction abstraction (or meta transactions, if you prefer) isn't a new idea in Ethereum. The idea, roughly, is that users sometimes want a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found