Skip to content

Commit

Permalink
added in txn history API spec
Browse files Browse the repository at this point in the history
  • Loading branch information
pileofscraps committed Feb 25, 2025
1 parent f2e484e commit d0e7ff4
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Category:
- private-transactions
- notify
- transaction-simulation
- transactions
# - accounts
80 changes: 80 additions & 0 deletions evm_body.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,86 @@ alchemy_getAssetTransfers:
type: string
description: 'String - UUID for pagination. If more results are available, a uuid pageKey will be returned in the response. Pass that uuid into pageKey to fetch the next 1000 or maxCount.'

# ============= Txn History API Methods ===============
by-address:
allOf:
- $ref: '#/common_request_fields'
- type: object
properties:
method:
$ref: ./components/schemas.yaml#/Method
default: by-address
params:
type: array
minItems: 1
maxItems: 1
items:
type: object
required:
- category
properties:
fromBlock:
type: string
description: 'String - Inclusive from block (hex string, int, `latest`, or `indexed`). Defaults to `0x0`'
default: '0x0'
toBlock:
type: string
description: 'String - Inclusive to block (hex string, int, `latest`, or `indexed`). Defaults to `latest`. Read more about block tags <span class="custom-style"><a href="https://docs.alchemy.com/reference/transfers-api-quickstart#what-are-the-different-types-of-block-tags" target="_blank">here</a></span>'
default: latest
fromAddress:
type: string
description: String - From address (hex string). Default wildcard - any address
pattern: '^0[xX][0-9a-fA-F]+$'
toAddress:
type: string
description: String - To address (hex string). Default wildcard - any address
pattern: '^0[xX][0-9a-fA-F]+$'
default: '0x5c43B1eD97e52d009611D89b74fA829FE4ac56b1'
contractAddresses:
type: array
description: 'String - List of contract addresses (hex strings) to filter for - only applies to "erc20", "erc721", "erc1155" transfers. Default wildcard - any address'
items:
type: string
pattern: '^0[xX][0-9a-fA-F]+$'
category:
type: array
minItems: 1
description: |
'Array of categories, can be any of the following: "external", "internal", "erc20", "erc721", "erc1155", or "specialnft". See the table above for supported categories on each network.'
items:
type: string
enum:
- external
- internal
- erc20
- erc721
- erc1155
- specialnft
default: external
order:
type: string
description: |
String - Whether to return results in ascending (`asc`) or descending (`desc`) order. Ascending order is from oldest to newest transactions, descending order is from newest to oldest. Defaults to `asc`.
enum:
- asc
- desc
withMetadata:
type: boolean
description: Boolean - Whether or not to include additional metadata about each transfer event. Defaults to `false`.
default: false
excludeZeroValue:
type: boolean
description: Boolean - A boolean to exclude transfers with zero value - zero value is not the same as null value. Defaults to `true`.
default: true
maxCount:
type: string
description: Max hex string number of results to return per call. Defaults to `0x3e8` (1000).
default: '0x3e8'
pageKey:
type: string
description: 'String - UUID for pagination. If more results are available, a uuid pageKey will be returned in the response. Pass that uuid into pageKey to fetch the next 1000 or maxCount.'


# ============= Debug API Methods ===============
tracer:
type: string
Expand Down
136 changes: 136 additions & 0 deletions evm_responses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,27 @@ log_object:
type: string
description: Hash of the transactions this log was created from. null when its pending log.

txn_history_log_object:
type: object
properties:
contractAddress:
type: string
description: 20 Bytes - contract address from which this log originated.
logIndex:
type: string
description: Integer of the log index position in the block. null when its pending log.
data:
type: string
description: Contains one or more 32 Bytes non-indexed arguments of the log.
removed:
type: boolean
description: 'true when the log was removed, due to a chain reorganization. false if its a valid log.'
topics:
type: array
items:
type: string
description: 'Array of zero to four 32 Bytes DATA of indexed log arguments'

block_object:
allOf:
- $ref: '#/nonce_hash_block'
Expand Down Expand Up @@ -879,6 +900,39 @@ action_object:
type: string
value:
type: string
txn_history_trace_object:
type: object
properties:
type:
type: string
description: CALL or CREATE
fromAddress:
type: string
description: 20 Bytes - address of the sender
toAddress:
type: string
description: 20 Bytes - address of the receiver. null when its a contract creation transaction
value:
type: string
description: amount of value for transfer (in hex)
gas:
type: string
description: amount of gas provided for the call (in hex)
gasUsed:
type: string
description: amount of gas used during the call (in hex)
input:
type: string
description: call data
output:
type: string
description: return data
error:
type: string
description: error, if any
revertReason:
type: string
description: solidity revert reason, if any
trace_filter:
allOf:
- $ref: '#/common_response_fields'
Expand Down Expand Up @@ -1257,6 +1311,88 @@ eth_createAccessList:
example:
$ref: ./evm_examples.yaml#/eth_createAccessList

# ============= Txn History API Methods ===============
by-address:
allOf:
- type: object
properties:
result:
type: object
description: 'An object with the following fields.'
properties:
before:
type: string
description: 'The cursor that points to the previous set of results.'
after:
type: string
description: 'The cursor that points to the end of the current set of results.'
totalCount:
type: integer
description: 'Total count of the response items.'
transfers:
type: array
description: 'Array of objects - sorted in ascending order by time'
items:
$ref: '#/transaction_history_top_object'
transaction_history_top_object:
type: object
properties:
network:
type: string
description: "Network associated with an individual transaction"
hash:
type: string
description: 'Transaction hash'
timeStamp:
type: string
description: '(ISO 8601) Timestamp of transaction mining / confirmation'
blockNumber:
type: integer
description: 'Block number of transaction mining / confirmation'
blockHash:
type: string
description: 'Block hash of transaction mining / confirmation'
status:
type: string
description: '[”confirmed”, “failed”, “removed”]'
nonce:
type: integer
description: 'Transaction nonce'
transactionIndex:
type: integer
description: 'Position of transaction within a block'
fromAddress:
type: string
description: 'From address of transaction (hex string).'
toAddress:
type: string
description: 'To address of transaction (hex string). null if contract creation.'
contractAddress:
type: string
description: '20 Bytes - The contract address created, if the transaction was a contract creation, otherwise null'
value:
type: string
description: "(uint8) Value of native token value moved within the external transaction"
cumulativeGasUsed:
type: string
description: The total amount of gas used when this transaction was executed in the block.
effectiveGasPrice:
type: string
description: Gas price parameter
gasUsed:
type: string
description: The amount of gas used by this specific transaction alone
logs:
type: array
description: 'Array of log objects, which this transaction generated'
items:
$ref: '#/txn_history_log_object'
internalTxns:
type: array
description: 'Array of internal transaction objects, which this transaction generated'
items:
$ref: '#/txn_history_trace_object'

# ============= Transfers API Methods ===============
alchemy_getAssetTransfers:
allOf:
Expand Down
2 changes: 1 addition & 1 deletion notify/notify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
get:
summary: Read Variable Elements
description: |
This endpoint allows you to read the values within a Custom Webhook variable.
This endpoint allows you to read the values within a Custom Webhook variable.
It supports pagination with `limit` and `after` query parameters.
tags: ['Custom Webhook API Methods']
parameters:
Expand Down
134 changes: 134 additions & 0 deletions transactions/transactions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
openapi: 3.1.0
info:
title: 📝 Transaction History
version: "1.0"
servers:
- url: https://api.g.alchemy.com/data
x-sandbox:
category:
type:
$ref: '../components/sandbox.yaml#/Category'
value: transactions
paths:

"/v1/{apiKey}/assets/transactions/by-address":
post:
summary: Transactions by Address
description: The Transaction History API endpoint allows you to query historical transactions for any address, across all chains
tags: ["Txn History API Endpoints"]
x-readme:
samples-languages:
- javascript
- curl
- python
- go
parameters:
- $ref: '#/components/schemas/apiKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/TransactionsByAddressRequest"
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: ../evm_responses.yaml#/by-address
"400":
description: 'Bad Request: Invalid input (e.g., malformed JSON).'
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"429":
description: 'Too Many Requests: Rate limit exceeded.'
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
operationId: by-address


components:
securitySchemes:
apiKey:
type: apiKey
name: Authorization
in: header
description: An API key that will be supplied in a named header.
x-default: Bearer API_KEY
schemas:
apiKey:
name: apiKey
in: path
schema:
type: string
default: docs-demo
description: |
<style>
.custom-style {
color: #048FF4;
}
</style>
For higher throughput, <span class="custom-style"><a href="https://alchemy.com/?a=docs-demo" target="_blank">create your own API key</a></span>
required: true

TransactionsByAddressRequest:
type: object
properties:
after:
required: false
schema:
type: string
description: 'The cursor that points to the end of the current set of results.'
before:
required: false
schema:
type: string
description: 'The cursor that points to the previous set of results.'
address:
description: Owner wallet address (that can map to a 'from' or 'to' address)
example: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
default: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
# Vitalik's ETH address
network:
type: array
minItems: 1
description:
Array of token networks; limited network support while in BETA
items:
$ref: "#/components/schemas/networkItem"
maxItems: 1
required:
- addresses

networkItem:
type: string
example: ETH_MAINNET
default: ETH_MAINNET
description: |
<style>
.custom-style {
color: #048FF4;
}
</style>
Network identifier (e.g., eth-mainnet). Find more network enums <span class="custom-style"><a href="https://dashboard.alchemy.com/chains" target="_blank">here</a></span>
required: true

ErrorResponse:
type: object
properties:
error:
type: object
properties:
message:
type: string
description: Detailed error message.
required:
- message
description: Error details.
required:
- error

0 comments on commit d0e7ff4

Please sign in to comment.