πŸ‘“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

chevron-rightπŸ“’ INSTRUCTION_ACCOUNT hashtag

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"
}
chevron-rightπŸ“› INSTRUCTION_NAMEhashtag

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"
}
chevron-rightπŸͺ΅ INSTRUCTION_LOGShashtag

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"
}
chevron-right1️⃣ INSTRUCTION_ARG_NUMERIChashtag

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
    }
}
chevron-rightπŸ’­ INSTRUCTION_ARG_KEYWORDhashtag

Description:

Search for instructions with specific string keyword arguments present

Schema fields:

  • type*

  • path*

  • value*

Schema

Example - 1

Example - 2

chevron-rightβœ… INSTRUCTION_ARG_EXISTShashtag

Description:

Search for instructions where a specific argument key is present

Schema fields:

  • type*

  • path*

Schema

Example

chevron-right⚠️ INSTRUCTION_ERROR_CODEhashtag

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

chevron-right☎️ INSTRUCTION_CPI_INVOKERhashtag

Description:

Search for instructions where a CPI has been invoked

Schema fields:

  • type*

  • cpiProgramId

Schema

Example

chevron-rightπŸ’° INSTRUCTION_BALANCEShashtag

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.

chevron-rightπŸ“… INSTRUCTION_EVENT_EXISTShashtag

Description:

Search for instructions where a specific Anchor event name is present

Schema fields:

  • type*

  • eventName*

Schema

Example

chevron-right2️⃣ INSTRUCTION_EVENT_DATA_NUMERIChashtag

Description:

Search for instructions with specific event numeric values present

Schema fields:

  • type*

  • eventName*

  • path*

  • range*

Schema

NumericRange type

Example - 1

Example - 2

chevron-rightπŸ”€ INSTRUCTION_EVENT_DATA_KEYWORDhashtag

Description:

Search for instructions with specific string keywords present in the events

Schema fields:

  • type*

  • eventName*

  • path*

  • value*

Schema

Example -

chevron-rightπŸ“Š INSTRUCTION_EVENT_DATA_EXISTShashtag

Description:

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

Schema fields:

  • type*

  • eventName*

  • path*

Schema

Example

chevron-rightπŸ” INSTRUCTION_TRANSFERShashtag

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