Skip to content

Commit

Permalink
Merge pull request #347 from alchemyplatform/getRecentBlockhash
Browse files Browse the repository at this point in the history
add `getRecentBlockhash` solana endpoint
  • Loading branch information
SahilAujla authored Jan 26, 2024
2 parents e321fd8 + 89c2800 commit f959520
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/sync-apis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,12 @@ jobs:
working-directory: ./solana
run: rdme openapi sendTransaction.yaml --key=$README_API_KEY --id=62d9832db4d7bf001a180ea3

- name: Update Solana API - getRecentBlockhash
env:
README_API_KEY: ${{ secrets.README_API_KEY }}
working-directory: ./solana
run: rdme openapi getRecentBlockhash.yaml --key=$README_API_KEY --id=65b40be89801a0001c5f3b19


# Update Starknet APIs
- name: Update Starknet API - starknet_addDeclareTransaction
Expand Down
52 changes: 52 additions & 0 deletions solana/getRecentBlockhash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
openapi: 3.1.0
info:
title: Recent Blockhash
version: '1.0'
servers:
- url: 'https://{network}.g.alchemy.com/v2/'
variables:
network:
enum:
- solana-mainnet
- solana-devnet
default: solana-mainnet
x-sandbox:
category:
type:
$ref: '../components/sandbox.yaml#/Category'
value: core
paths:
/{apiKey}:
post:
summary: getRecentBlockhash
description: Returns a recent block hash from the ledger, and a fee schedule that can be used to compute the cost of submitting a transaction using it.
tags: []
parameters:
- 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
requestBody:
content:
application/json:
schema:
$ref: solana_body.yaml#/getRecentBlockhash
responses:
'200':
description: ''
content:
application/json:
schema:
$ref: solana_responses.yaml#/getRecentBlockhash
operationId: getRecentBlockhash
x-readme:
explorer-enabled: false
24 changes: 24 additions & 0 deletions solana/solana_body.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,30 @@ filters:
format: int64
description: Compares the program account data length with the provided data size.

getRecentBlockhash:
allOf:
- $ref: '#/common_request_fields'
- type: object
properties:
method:
$ref: '../components/schemas.yaml#/Method'
default: getRecentBlockhash
params:
type: array
minItems: 1
maxItems: 1
items:
type: object
properties:
commitment:
type: string
default: finalized
description: |
The level of commitment desired for the query. Options include:
- **finalized**: The node will request the latest block that has been confirmed by the majority of the cluster as having achieved full lockout, indicating that the cluster has acknowledged this block as finalized.
- **confirmed**: The node will request the latest block which has received votes from the vast majority of the cluster.
- **processed**: The node will request information on its latest block, keeping in mind that this block might not be fully complete.
# ======= Definitions for blockNumber ==========
# blockNumber or slotnumber is used in many API endpoints so creating a separate component for it
block_number:
Expand Down
26 changes: 26 additions & 0 deletions solana/solana_responses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -977,3 +977,29 @@ requestAirdrop:
type: string
description: Transaction Signature of the airdrop, as a base-58 encoded string
example: 5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW

getRecentBlockhash:
allOf:
- $ref: '#/common_response_fields'
- type: object
nullable: true
properties:
result:
type: object
description: A JSON object.
properties:
context:
type: object
properties:
slot:
type: integer
description: The current slot in the Solana cluster.
value:
type: object
properties:
blockhash:
type: string
description: The blockhash for the specified transaction.
feeCalculator:
type: object
description: A JSON object that represents the fee calculator for the specified transaction.

0 comments on commit f959520

Please sign in to comment.