v2

latestOpenAPI 3.0.3Apache 2.0raw.githubusercontent.com2022-07-19176455.9 KB
events

Get events by event handle

This API extracts event key from the account resource identified by the event_handle_struct and field_name, then returns events identified by the event key.

get/accounts/{address}/events/{event_handle_struct}/{field_name}

Path parameters

addressstring address required

Hex-encoded 16 bytes Aptos account address.

Prefixed with 0x and leading zeros are trimmed.

See doc for more details.

Example:0xdd
event_handle_structstring move_type required

String representation of an on-chain Move struct type.

It is a combination of:

  1. Move module address, module name and struct name joined by ::.
  2. struct generic type parameters joined by , .

Examples:

  • 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
  • 0x1::account::Account

Note:

  1. Empty chars should be ignored when comparing 2 struct tag ids.
  2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding).

See doc for more details.

Example:0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
field_namestring required

The field name of the EventHandle in the struct.

Query parameters

startinteger

The start sequence number in the EVENT STREAM, defaulting to the latest event. The events are returned in the reverse order of sequence numbers.

limitinteger

The number of events to be returned for the page default is 5

Response

Returns events

keystring hex required

Event key is a global index for an event stream.

It is hex-encoded BCS bytes of EventHandle guid field value, which is a combination of a uint64 creation number and account address (without trimming leading zeros).

For example, event key 0x00000000000000000000000000000000000000000a550c18 is combined by the following 2 parts:

  1. 0000000000000000: uint64 representation of 0.
  2. 0000000000000000000000000a550c18: 16 bytes of account address.
sequence_numberstring uint64 required

Event sequence_number is unique id of an event in an event stream. Event sequence_number starts from 0 for each event key.

typestring required

String representation of an on-chain Move type tag that is exposed in transaction payload.

Values:

  • bool
  • u8
  • u64
  • u128
  • address
  • signer
  • vector: vector<{non-reference MoveTypeId}>
  • struct: {address}::{module_name}::{struct_name}::<{generic types}>

Vector type value examples:

  • vector<u8>
  • vector<vector<u64>>
  • vector<0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>>

Struct type value examples:

  • `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>
  • 0x1::account::Account

Note:

  1. Empty chars should be ignored when comparing 2 struct tag ids.
  2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding).
datastring required

Move bool type value is serialized into boolean.

Move u8 type value is serialized into integer.

Move u64 and u128 type value is serialized into string.

Move address type value(16 bytes Aptos account address) is serialized into hex-encoded string, which is prefixed with 0x and leading zeros are trimmed.

For example:

  • 0x1
  • 0x1668f6be25668c1a17cd8caf6b8d2f25

Move vector type value is serialized into array, except vector<u8> which is serialized into hex-encoded string with 0x prefix.

For example:

  • vector<u64>{255, 255} => ["255", "255"]
  • vector<u8>{255, 255} => 0xffff

Move struct type value is serialized into object that looks like this (except some Move stdlib types, see the following section):

{
  field1_name: field1_value,
  field2_name: field2_value,
  ......
}

For example: { "created": "0xa550c18", "role_id": "0" }

Special serialization for Move stdlib types:

  • 0x1::string::String is serialized into string. For example, struct value 0x1::string::String{bytes: b"hello world"} is serialized as "hello world" in JSON.

Example response

[
  {
    "key": "0x00000000000000000000000000000000000000000a550c18",
    "sequence_number": "23",
    "type": "0x1::account::CreateAccountEvent",
    "data": {
      "created": "0xa550c18",
      "role_id": "0"
    }
  }
]