I have created a Defender and also added the autotasks for interacting with the relayer, and this is functioning properly. In my sample project, when clicking a button, it utilizes the webhook from the autotasks and then executes the transaction.
The issue I am facing is that the "from" address of the transaction belongs to the relayer, which is not the desired behavior. Instead, I want to use the wallet address of the user. Currently, I am not getting a popup from MetaMask to sign the request for the transaction.
Environment
Details
autotasks code
const { DefenderRelaySigner, DefenderRelayProvider } = require('defender-relay-client/lib/ethers');
const ethers = require('ethers');
exports.handler = async function(event) {
const provider = new DefenderRelayProvider(event);
const signer = new DefenderRelaySigner(event, provider, { speed: 'fast' });
// Use provider and signer for querying or sending txs from ethers, for example...
const ADDRESS = '0x24D8aF7944869314B7EE6C34a5FF1582Ca6D4630'
const gasLimit = 300000;
const value = event.request.body;
const ABI =[...]
const contract = new ethers.Contract(ADDRESS, ABI, signer);
//await contract.register("Hello")
await contract.register(value, { gasLimit });
}
how I am calling the webhook code
const handleTriggerAutotask = async () => {
try {
const response = await fetch(
"WEBHOOK_URL",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(inputData),
}
);
const data = await response.json();
setStatus(data.status);
} catch (error) {
console.error("Error triggering Autotask:", error);
setStatus("Error");
}
};
Code to reproduce
I am directly calling the handleTriggerAutotask on a button click, but don't know how to integrate this with the metamask for signing the request