The docs show it's possible to perform private transactions (flashbots) with a relayer
Is it possible to do this with autotasks, and if so what's the best way?
Environment
executing a transaction with Autotasks
Details
Doc examples (copy pasta below) show you can just use the signer as a regular ethers signer, however this doesn't take any of the DefenderTransactionRequest
params such as
isPrivate?: boolean;
- If I wish to make private, do i need to use
signer.sendTransaction()
instead? - Does the "Send Private Transactions by default" option in the relayer affect transactions via Autotask too?
- The example from docs has a note to intentionally not wait for the
tx.wait()
- At what point is the tx actually mined, and what is the flow of the monitoring/resubmitting?
- I need to pull a value off-chain once the tx has been mined, so in this case I need to wait. Is that correct?
Code to reproduce
// Entrypoint for the Autotask
exports.handler = async function(event) {
// Load value provided in the webhook payload (not available in schedule or sentinel invocations)
const { value } = event.request.body;
// Compare it with a local secret
if (value !== event.secrets.expectedValue) return;
// Initialize defender relayer provider and signer
const provider = new DefenderRelayProvider(event);
const signer = new DefenderRelaySigner(event, provider, { speed: 'fast' });
// Create contract instance from the signer and use it to send a tx
const contract = new ethers.Contract(ADDRESS, ABI, signer);
if (await contract.canExecute()) {
const tx = await contract.execute();
console.log(`Called execute in ${tx.hash}`);
return { tx: tx.hash };
}
}