πŸ‘“Instruction Filters

All filter types that can be applied to instruction query 'filter' objects

Overview

Several of Carpool's instruction queries accept a filter object in the POST body. This is an abstraction on top of Elasticsearch and is made to help users perform powerful aggregations and searches. Below you can find all possible filters for instruction queries

Instruction Filters

πŸ“’ INSTRUCTION_ACCOUNT

Description:

Filter for instructions that contain a specific account

Schema fields:

  • type*

  • accountPubKey*

  • accountName

Schema

"filter": {
    "type": "INSTRUCTION_ACCOUNT",
    "accountPubKey": "string",
    "accountName": "string" // A specific account in an instruction's args (via IDL). Leave blank to match any account in the instruction.
}

Example

"filter": {
    "type": "INSTRUCTION_ACCOUNT",
    "accountPubKey": "8mpTNU6vpLSD9mWx4BQt2S6sz2yP39ZhQ9TuMXY4MgUz",
    "accountName": "authority"
}
πŸ“› INSTRUCTION_NAME

Description:

Filter for instructions that contain a specific instruction name

Schema fields:

  • type*

  • instructionName*

Schema

"filter": {
    "type": "INSTRUCTION_NAME",
    "instructionName": "string"
}

Example

"filter": {
    "type": "INSTRUCTION_NAME",
    "instructionName": "depositFunds"
}
πŸͺ΅ INSTRUCTION_LOGS

Description:

Filter for instructions that contain the searched text in the their logs

Schema fields:

  • type*

  • searchText*

Schema

"filter": {
    "type": "INSTRUCTION_LOGS",
    "searchText": "string"
}

Example

"filter": {
    "type": "INSTRUCTION_LOGS",
    "searchText": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
}
1️⃣ INSTRUCTION_ARG_NUMERIC

Description:

Search for instructions with specific numeric arguments present

Schema fields:

  • type*

  • path*

  • range*

Schema

"filter": {
    "type": "INSTRUCTION_ARG_NUMERIC",
    "path": "string", // Dot-delimited for nested fields
    "range": NumericRange
}

NumericRange type

// Either an equality check, or GTE/LTE range, one of which must be set.
export type NumericRange = XOR<XOR<{
  gte: number;
  lte?: number;
}, {
  gte?: number;
  lte: number;
}>, { eq: number }>;

Example - 1

"filter": {
    "type": "INSTRUCTION_ARG_NUMERIC",
    "path": "args.clientOrderId",
    "range": {
        "gte": 2
    }
}

Example - 2

"filter": {
    "type": "INSTRUCTION_ARG_NUMERIC",
    "path": "data.creators.percentageShare",
    "range": {
        "eq": 100
    }
}
πŸ’­ INSTRUCTION_ARG_KEYWORD

Description:

Search for instructions with specific string keyword arguments present

Schema fields:

  • type*

  • path*

  • value*

Schema

Example - 1

Example - 2

βœ… INSTRUCTION_ARG_EXISTS

Description:

Search for instructions where a specific argument key is present

Schema fields:

  • type*

  • path*

Schema

Example

⚠️ INSTRUCTION_ERROR_CODE

Description:

Search for failed instructions where an errorCode is present. Note - you must have "failures" set to true within your query object in your POST body

Schema fields:

  • type*

  • errorCode

Schema

Example

☎️ INSTRUCTION_CPI_INVOKER

Description:

Search for instructions where a CPI has been invoked

Schema fields:

  • type*

  • cpiProgramId

Schema

Example

πŸ’° INSTRUCTION_BALANCES

Description:

Search for instructions that match a specified balance or range.

Schema fields:

  • type*

  • accountPubKey

  • token

  • delta

Schema

NumericRange Type

Example - 1

Example - 2

This example can be used to find an instance(s) where a particular accountPubKey paid an exact amount of SOL.

πŸ“… INSTRUCTION_EVENT_EXISTS

Description:

Search for instructions where a specific Anchor event name is present

Schema fields:

  • type*

  • eventName*

Schema

Example

2️⃣ INSTRUCTION_EVENT_DATA_NUMERIC

Description:

Search for instructions with specific event numeric values present

Schema fields:

  • type*

  • eventName*

  • path*

  • range*

Schema

NumericRange type

Example - 1

Example - 2

πŸ”€ INSTRUCTION_EVENT_DATA_KEYWORD

Description:

Search for instructions with specific string keywords present in the events

Schema fields:

  • type*

  • eventName*

  • path*

  • value*

Schema

Example -

πŸ“Š INSTRUCTION_EVENT_DATA_EXISTS

Description:

Search for instructions where a specific Anchor event data fields is present

Schema fields:

  • type*

  • eventName*

  • path*

Schema

Example

πŸ” INSTRUCTION_TRANSFERS

Description:

Search for instructions with specific transfers done on an instruction level

Schema fields:

  • type*

  • from

  • to

  • fromOwner

  • toOwner

  • mint

  • amount

Schema

NumericRange Type

Example - 1

Example - 2

Combining Filters

It is important to note that you can also combine any of the above filters within a single query. You can return results based on an AND or OR condition.

AND

Schema

Example

OR

Schema

Example

Negating Filters

You can also negate filters if you'd like to look for all instructions that do not match the filter criteria. To negate, simply add "negate": true to the top level of the filter.

Example

Last updated