Contract Creation

By setting a TRIGGER_TYPE_NEW_CONTRACT trigger you can be notified whenever a new contract is created.

The following function will send the address of the new contract, as well as the transaction hash to your webhook.

export const triggerHandler = (context, data) => {
    if (context.dataType === "DATA_TYPE_CONTRACT") {
        console.log("Transaction from " + data.creator + " to " + data.address);
        if (data.to === null) {
            console.log("New contract created at " + data.address);
            return {
                creator: data.creator,
                newContractAddress: data.address,
                txHash: context.txHash
            };
        }
    }

    return;
};