@spalladino you are right. Half my problems seem to have stemmed from having my autotask as a condition and not a trigger. Notifications would not fire, and the path to the transaction data was different as well (as you mentioned on the other thread here )
I now create a new problem though
At the end of my autotask I need to send data back to a smart contract. When I had my autotask set up as a condition, I was able to use ethers and fire out a transaction. The basic format of what I did looked like this:
const { ethers } = require("ethers")
const { DefenderRelaySigner, DefenderRelayProvider } = require('defender-relay-client/lib/ethers')
const address = ' '
const ABI = [ ]
exports.handler = async function(credentials) {
const provider = new DefenderRelayProvider(credentials)
const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fast' })
const contract= new ethers.Contract(address, ABI, signer)
const txRes = await contract.function(var_1, var_2, var_3)
return txRes.hash
}
While I don't get an autotask error (the autotask runs successfully), I do not see a transaction emitted to the smart contract via the autotask. As mentioned, this worked fine when the autotask was a condition (maybe I changed something and the difference between an autotask notification vs condition is not relevant).
I was able to see the following result back from the autotask console which might be helpful? From what I googled, this message is related to AWS-Lambda:
{"message":"Missing required key 'FunctionName' in params","code":"MissingRequiredParameter","time":"2021-07-30T00:22:06.631Z"}
I checked the documentation and there is an alternative way by using:
const { Relayer } = require('defender-relay-client')
exports.handler = async function(credentials) {
const relayer = new Relayer(credentials)
// Use relayer for sending txs or querying the network
I don't think the relayer method above is needed, but please correct me if I am wrong so I can pursue that route.