How can I implement a meta-transaction using ethers.js library or at least have another account paying a transaction, which was signed by different account?
Consider a transaction to transfer 100 ERC20-tokens using a ERC20-contract from 0xAccountA
to 0xAccountB
. The transaction will be signed by 0xAccountA
but the gas would be payed by some other 0xAccountC
.
Lets initiate a contract:
const abi = ['function transferFrom(address sender, address recipient, uint256 amount)'];
const payer = new ethers.Wallet(privKey, provider);
const contract = new ethers.Contract(contractAddress, abi, payer);
Currently, we create transactions like this;
const contractWithFromAsSigner = contract.connect(from);
const tx = await contractWithFromAsSigner.transferFrom(from, to, amount);
In this case, from
has to sign the transaction and is also paying for the transaction.
What I'd like to achieve is that from
is signing this transaction, but payer
is paying and really broadcasting the transaction, which was signed by from
, but paid by payer
.
How can I do that?