Mutations

Write-mode: ON ;)

GraphQL mutations create and modify objects, and they are similar to PUT, POST, or DELETE requests in REST. Mutation requests share the same endpoint with query requests.

You can use mutations to create or modify a trigger. Mutations have the following structure:

  • An operation name

  • A field name, such as createTransactionsTrigger

  • The input data to use in the mutation passed as an argument, such as the details of the new trigger

  • A selection of return fields that should be included in the response, such as the UUID of the successfully created Trigger object

Available mutations

In HAL the following mutations are available:

Mutations Name

Scope

createTransactionsTrigger

To create a TransactionsTrigger

createEventsTrigger

To create an EventsTrigger

createContractsTrigger

To create a ContractsTrigger

updateTriggerStatus

To update a trigger status from active to inactive or viceversa

Examples

Create a TransactionsTrigger

Query
Result
Query
mutation {
createTransactionsTrigger(input: {
name: "Watch Transactions Example",
type: TransactionsTrigger,
statement: {
filters: [
{
condition: {
attribute: "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
predicate: Eq
},
parameter: {
name: "To"
},
type: BasicFilter
},
{
method: {
name: "trade"
},
parameter: {
name: "tradeValues",
type: "uint256[8]",
index: 1
},
type: CheckFunctionParameter,
condition: {
attribute: "100",
predicate: BiggerThan
}
},
{
method: {
name: "trade"
},
parameter: {
name: "tradeAddresses",
type: "address[4]",
index: 1
},
type: CheckFunctionParameter,
condition: {
attribute: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
predicate: Eq
}
}
],
contract: {
address: "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
abi: [...]
}
},
actions: [
{
type: Email,
attributes: {
body: "BlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\nFrom is $From$\nTo is $To$\nValue is $Value$\nGas is $Gas$\nGasPrice is $GasPrice$\nNonce is $Nonce$",
subject: "Watch Transactions Example",
to: [
"matteo@atomic.eu.com"
]
}
}
]
}) {
UUID
}
}
Result
{
"data": {
"createTransactionsTrigger": {
"UUID": "5b2d1664-8215-4910-9186-241a8f8385f9"
}
}
}

Create an EventsTrigger

Query
Result
Query
mutation {
createEventsTrigger(input: {
name: "EventsTrigger Example",
type: EventsTrigger,
statement: {
contract: {
address: "0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208",
abi: [...]
},
filters: [
{
method: {
name: "Trade"
},
parameter: {
name: "amountBuy",
type: "uint256",
index: null
},
type: CheckEventParameter,
condition: {
attribute: "10000000",
predicate: BiggerThan
}
},
{
method: {
name: "Trade"
},
parameter: {
name: "amountSell",
type: "uint256",
index: null
},
type: CheckEventParameter,
condition: {
attribute: "0877482451441745527442663152",
predicate: Eq
}
}
]
},
actions: [
{
type: Email,
attributes: {
body: "BlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nTransactionHash is $TransactionHash$\nBlockTimestamp is $BlockTimestamp$\n\nEvent name is: $MethodName$",
subject: "EventsTrigger Example",
to: [
"matteo@atomic.eu.com"
]
}
}
]
}) {
UUID
}
}
Result
{
"data": {
"createEventsTrigger": {
"UUID": "39d3cc06-83ef-4bc2-b580-dcdc75466360"
}
}
}

Create a ContractsTrigger

Query
Result
Query
mutation {
createContractsTrigger(input: {
name: "ContractsTrigger Example",
type: ContractsTrigger,
statement: {
contract: {
address: "0x09cabec1ead1c0ba254b09efb3ee13841712be14",
abi: [...]
},
inputs: [
{
type: "uint256",
name: "eth_bought",
value: "1"
}
],
outputFilters: [
{
parameter: {
type: "uint256",
name: "out"
},
returnIndex: 0,
condition: {
attribute: "140",
predicate: BiggerThan
}
}
],
method: {
name: "getTokenToEthOutputPrice"
}
},
actions: [
{
type: Email,
attributes: {
body: "BlockNumber is $BlockNumber$\nBlockHash is $BlockHash$\nBlockTimestamp is $BlockTimestamp$\n\nThe contract wich originated this trigger is: $ContractAddress$\n\nAll values returned by the function: $ReturnedValues$",
subject: "ContractsTrigger Example",
to: [
"matteo@atomic.eu.com"
]
}
}
]
}) {
UUID
}
}
Result
{
"data": {
"createContractsTrigger": {
"UUID": "8b944a2f-da6b-41a6-895b-c39fcac5011e"
}
}
}

Update a trigger status

Query
Result
Query
mutation {
updateTriggerStatus(input: {UUID: "5b2d1664-8215-4910-9186-241a8f8385f9", isActive: false}) {
UUID
isActive
}
}
Result
{
"data": {
"updateTriggerStatus": {
"UUID": "5b2d1664-8215-4910-9186-241a8f8385f9",
"isActive": false
}
}
}