Aptos — Accounts, Blocks, Events, General, Table, Transactions (2/2)
API reference for Aptos. All methods ->
Part 2 of 2: 1 · 2
Transactions
Get transactions
GET
https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions
Retrieves on-chain committed transactions. The page size and start ledger version can be provided to get a specific sequence of transactions.
If the version has been pruned, then a 410 will be returned.
To retrieve a pending transaction, use Get transactions by hash.
Parameters
limit(integer; query): max number of events to retrieve. If unspecified, defaults to default page size.start(string; uint64; query): a ledger version to start th list of transactions. If not provided, defaults to showing the latest transactions
Example:32425224034
Request example
curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions \
-H 'Content-Type: application/json'
Response example
[
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]
Submit transaction
POST
https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions
This endpoint accepts transaction submissions in two formats.
To submit a transaction as JSON, you must create a SubmitTransactionRequest. To build this request, do the following:
- Encode the transaction as BCS. If you are using a language that has
- Sign the encoded transaction and use it to create a TransactionSignature.
- Submit the request. Make sure to use the "application/json" Content-Type.
To submit a transaction as BCS, you must submit a SignedTransaction encoded as BCS. Make sure to use the application/x.aptos.signed_transaction+bcs Content-Type.
Parameters
Request is an application/json body with the following parameters:
sender(string; hex; required): a hex-encoded 32-byte Aptos account address. This is represented in a string as a 64 character hex string, sometimes shortened by stripping leading 0s, and adding a 0x. For example, address0x0000000000000000000000000000000000000000000000000000000000000001is represented as0x1.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1sequence_number(string; uint64; required): a string containing a 64-bit unsigned integer. We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.
Example:32425224034max_gas_amount(string; uint64; required): a string containing a 64-bit unsigned integer. We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.
Example:32425224034gas_unit_price(string; uint64; required): a string containing a 64-bit unsigned integer. We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.
Example:32425224034expiration_timestamp_secs(string; uint64; required): a string containing a 64-bit unsigned integer. We represent u64 values as a string to ensure compatibility with languages such as JavaScript that do not parse u64s in JSON natively.
Example:32425224034payload(object; required): a payload is one of the following objects:- A payload which runs a single entry function:
type(string; required): a payload type. Example:entry_function_payload.function(string; required): an entry function ID is a string representation of an entry function defined on-chain.
Format:{address}::{module name}::{function name}
Bothmodule nameandfunction nameare case-sensitive.
Example:0x1::aptos_coin::transfertype_arguments(array[string]; required): type arguments of the function.arguments(array; required): arguments of the function.
- A payload which runs a script that can run multiple functions:
type(string; required): a payload type. Example:script_payload.code(object; required): a Move script bytecode:bytecode(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with0xand fulfilled with two hex digits per byte.
Unlike theAddresstype, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1abi(object): a Move function:name(string; required): a name of the function.visibility(string; required): Move function visibility.
Allowed values:private,public,friendis_entry(boolean; required): whether the function can be called as an entry function directly in a transaction.generic_type_params(array[object]; required): generic type params associated with the Move function:constraints(array[string]; required): Move abilities tied to the generic type param and associated with the function that uses it.
params(array[string]; required): parameters associated with the Move function.return(array[string]: required): a return type of the function.
type_arguments(array[string]; required): type arguments of the function.arguments(array; required): arguments of the function.
- An enum of possible transaction payloads:
type(string; required): a payload type. Example:module_bundle_payload.modules(array[object]; required):bytecode(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike theAddresstype, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1abi(object): a Move module:address(string; hex; required): a hex-encoded 32-byte Aptos account address. This is represented in a string as a 64 character hex string, sometimes shortened by stripping leading 0s, and adding a 0x. For example, address0x0000000000000000000000000000000000000000000000000000000000000001is represented as0x1.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1name(string; required): a name of the module.friends(array[string]: required): friends of the module.exposed_functions(array[object]; required): public functions of the module:name(string; required): a name of the function.visibility(string; required): Move function visibility.
Allowed values:private,public,friendis_entry(boolean; required): whether the function can be called as an entry function directly in a transaction.generic_type_params(array[object]; required): generic type params associated with the Move function:constraints(array[string]; required): Move abilities tied to the generic type param and associated with the function that uses it.
params(array[string]; required): parameters associated with the Move function.return(array[string]; required): a return type of the function.
structs(array[object]; required): structs of the module:name(string; required): a name of the struct.is_native(boolean; required): whether the struct is a native struct of Move.abilities(array[string]; required): abilities associated with the struct.generic_type_params(array[object]; required): generic types associated with the struct:constraints(array[string]; required): Move abilities tied to the generic type param and associated with the type that uses it.
fields(array[object]; required): fields associated with the struct:name(string; required): a name of the field.type(string; required): a string representation of an on-chain Move type tag that is exposed in transaction payload.
Values: - bool - u8 - u16 - u32 - u64 - u128 - u256 - address - signer - vector:vector<{non-reference MoveTypeId}>- struct:{address}::{module_name}::{struct_name}::<{generic types}>Match pattern: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).^(bool|u8|u64|u128|address|signer|vector<.+>|0x[0-9a-zA-Z:_<, >]+)$
- A payload which runs a single entry function:
signature(object; required): a signature is one of the following objects:- A single Ed25519 signature:
type(string; required): a signature type. Example:ed25519_signature.public_key(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike theAddresstype, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1signature(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike theAddresstype, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- An Ed25519 multi-sig signature (allows k-of-n signing for a transaction):
type(string; required): a type of signature. Example:multi_ed25519_signature.public_keys(array[string]; hex; required): the public keys for the Ed25519 signature.signatures(array[string]; hex; required): signatures associated with the public keys in the same order.threshold(integer; required): the number of signatures required for a successful transaction.bitmap(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike theAddresstype, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- A multi-agent signature for multi-agent transactions (allows you to have transactions across multiple accounts):
type(string; required): a type of signature. Example:multi_agent_signature.sender(object; required): a sender is on of the following objects:- A single Ed25519 signature:
type(string; required): a type of sender signature. Example:ed25519_signature.public_key(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1signature(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- An Ed25519 multi-sig signature (allows k-of-n signing for a transaction):
type(string; required): a type of sender signature. Example:multi_ed25519_signature.public_keys(array[string]; hex; required): the public keys for the Ed25519 signature.signatures(array[string]; hex; required): signatures associated with the public keys in the same order.threshold(integer; required): the number of signatures required for a successful transaction.bitmap(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- A single Ed25519 signature:
secondary_signer_addresses(array[string]; hex; required): the other involved parties' addresses.secondary_signers(array of objects): an array of on of the following objects:- A single Ed25519 signature:
type(string; required): a type of secondary signers' signature. Example:ed25519_signature.public_key(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1signature(string; hex; required): all bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- An Ed25519 multi-sig signature (allows k-of-n signing for a transaction):
type(string; required): a type of secondary signers' signature. Example:multi_ed25519_signature.public_keys(array[string]; hex; required): the public keys for the Ed25519 signature.signatures(array[string]; hex; required): signatures associated with the public keys in the same order.threshold(integer; required): the number of signatures required for a successful transaction.bitmap(string; hex; required): bytes (Vec) data is represented as hex-encoded string prefixed with 0x and fulfilled with two hex digits per byte.
Unlike the Address type, HexEncodedBytes will not trim any zeros.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1
- A single Ed25519 signature:
- A single Ed25519 signature:
Request example
curl -X POST https://rpc.ankr.com/premium/YOUR_ANKR_API_KEY-http/aptos/YOUR_ANKR_API_KEY/v1/transactions \
-H 'Content-Type: application/json'
-d '{
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}'
Response example
{
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
Get transaction by hash
GET
https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions/by_hash/{txn_hash}
Retrieves a transaction by its hash. This is the same hash that is returned by the API when submitting a transaction (see PendingTransaction).
When given a transaction hash, the server first looks for the transaction in storage (on-chain, committed). If no on-chain transaction is found, it looks the transaction up by hash in the mempool (pending, not yet committed).
To create a transaction hash by yourself, do the following:
- Hash message bytes: "RawTransaction" bytes + BCS bytes of Transaction.
- Apply hash algorithm
SHA3-256to the hash message bytes. - Hex-encode the hash bytes with
0xprefix.
Parameters
txn_hash(string; path; required): a hash of the transaction to retrieve.
Request example
curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions/by_hash/{txn_hash} \
-H 'Content-Type: application/json'
Response example
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
Get transaction by version
GET
https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions/by_version/{txn_version}
Retrieves a transaction by a given version. If the version has been pruned, a 410 will be returned.
Parameters
txn_version(string; uint64; path; required): a version of the transaction to retrieve.
Example:32425224034
Request example
curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/transactions/by_version/{txn_version} \
-H 'Content-Type: application/json'
Response example
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
Get account transactions
GET
https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/transactions
Retrieves on-chain committed transactions from an account. If the start version is too far in the past, a 410 will be returned.
If no start version is given, it will start at version 0.
To retrieve a pending transaction, use Get transaction by hash.
Parameters
address(string; hex; path; required): an address of account with or without a0xprefix.
Example:0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1limit(integer; query): a max number of transactions to retrieve. If not provided, retrieves a default page size.start(string; uint64; query): a ledger version to start the list of transactions. If not provided, defaults to showing the latest transactions.
Example:32425224034
Request example
curl -X GET https://rpc.ankr.com/premium-http/aptos/YOUR_ANKR_API_KEY/v1/accounts/{address}/transactions \
-H 'Content-Type: application/json'
Response example
[
{
"type": "pending_transaction",
"hash": "string",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "entry_function_payload",
"function": "0x1::aptos_coin::transfer",
"type_arguments": [
"string"
],
"arguments": [
null
]
},
"signature": {
"type": "ed25519_signature",
"public_key": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 ",
"signature": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1 "
}
}
]