My understanding of Defender was, that I could use them to let someone else pay for a transaction that was signed with another account.
Lets say:
0xAccountA
sends ERC1155-tokens to 0xAccountB
, but 0xAccountC
is paying for that.
In order to achieve this, I did the following:
Given is apiKey
and secretKey
as response from
const key = await relayClient.createKey(relayerId);
Then I did:
const credentials = { apiKey: apiKey, apiSecret: secretKey };
const provider = new DefenderRelayProvider(credentials);
const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fast' });
console.log("Signer", await signer.getAddress())
const contract = new ethers.Contract(contractAddress, abi, signer);
tx = await contract.functions.safeTransferFrom(from, to, tokenId, amount, nullBytes);
I think, the misconception of my thoughts is, that the Signer must be the From
-address, because from
owns the tokens. But sending the transaction must be done with the Relayer-Account, which shall pay for that.
How can I achieve that from
is signing the transaction but the Relayer-Account is paying for it?
Environment
"defender-relay-client": "^1.30.0",
"ethers": "^5.6.0",
Details
see above
Code to reproduce
see above