### Example GET Request for Fork Information Source: https://docs.chainstack.com/reference/getforkinformation This example shows how to make a GET request to the /eth/v1/beacon/states/{state_id}/fork endpoint to fetch fork information for a given state ID. ```bash get https://beacon-nd-422-757-666.p2pify.com/0a9d79d93fb2f4a4b1e04695da2b77a7/eth/v1/beacon/states/{state_id}/fork ``` -------------------------------- ### Subscribe to New Heads using wscat Source: https://docs.chainstack.com/reference/gnosis-native-subscribe-newheads This example demonstrates how to subscribe to new block headers using the `wscat` command-line tool. Ensure you have `wscat` installed (`npm install -g wscat`) and replace `YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT` with your actual Chainstack WebSocket endpoint. ```APIDOC ## `eth_subscribe("newHeads")` with wscat ### Description Subscribe to new block headers using `wscat`. ### Method WebSocket ### Endpoint `YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT` ### Request Body ```json { "id": 1, "jsonrpc": "2.0", "method": "eth_subscribe", "params": ["newHeads"] } ``` ### Response Example ```json { "jsonrpc": "2.0", "result": "0x1" } ``` ### Notes - Requires a WebSocket connection. - Install `wscat` with `npm install -g wscat`. ``` -------------------------------- ### Subscribe to Solana Logs with wscat Source: https://docs.chainstack.com/reference/logssubscribe-solana This example demonstrates how to subscribe to Solana logs using `wscat`. Ensure you have installed `wscat` globally. Replace `YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT` with your actual endpoint. ```shell $ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT # Wait for the connection to be established Connected (press CTRL+C to quit) > {"jsonrpc":"2.0","id":1,"method":"logsSubscribe","params":[{"mentions":["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"]},{"commitment":"finalized"}]} ``` -------------------------------- ### Perp Deploy Action Example Source: https://docs.chainstack.com/reference/hyperliquid-exchange-perp-deploy Example of a POST request to the /exchange endpoint to deploy a perpetual future. This includes setting oracle prices for a DEX. Requires a valid EIP-712 signature. ```json { "action": { "type": "perpDeploy", "setOracle": { "dex": "xyz", "oraclePxs": [ [ "BTC", "50000.0" ] ], "markPxs": [ [ [ "BTC", "50000.0" ] ] ], "externalPerpPxs": [] } }, "nonce": 1705234567890, "signature": { "r": "0x0000000000000000000000000000000000000000000000000000000000000000", "s": "0x0000000000000000000000000000000000000000000000000000000000000000", "v": 27 }, "vaultAddress": null } ``` -------------------------------- ### eth_getBalance Request Example Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-balance This example shows the structure of a JSON-RPC request to get the balance of a specific Ethereum address at the latest block. ```json { "jsonrpc": "2.0", "method": "eth_getBalance", "params": [ "0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA", "latest" ], "id": 1 } ``` -------------------------------- ### Connect and Subscribe to Logs via WebSocket (wscat) Source: https://docs.chainstack.com/reference/avalanche-native-subscribe-logs Use this command-line example with wscat to establish a WebSocket connection and subscribe to specific event logs. Ensure you have wscat installed and replace YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT with your actual endpoint. ```shell $ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT # Wait for the connection to be established Connected (press CTRL+C to quit) > {"jsonrpc":"2.0","id": 1, "method": "eth_subscribe", "params": ["logs", {"address":"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]}]} ``` -------------------------------- ### net_peerCount Request Example Source: https://docs.chainstack.com/reference/hyperliquid-evm-net-peer-count This example shows the JSON-RPC request payload to get the number of connected peers. The method is 'net_peerCount' and parameters are an empty array. ```json { "jsonrpc": "2.0", "method": "net_peerCount", "params": [], "id": 1 } ``` -------------------------------- ### Execute System Transaction Analysis and Monitoring Examples Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-system-txs-by-block-number Demonstrates how to use the 'analyzeSystemTransactions' and 'monitorSystemTxsRange' functions with example block numbers. Logs the results or errors to the console. ```javascript // Usage examples analyzeSystemTransactions('0x9d16cf') .then(analysis => console.log('System Transaction Analysis:', analysis)) .catch(error => console.error('Error:', error)); // Monitor recent blocks for system activity monitorSystemTxsRange(10291248, 10291258) .then(monitoring => console.log('System Transaction Monitoring:', monitoring)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Transaction By Hash Request Example Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-transaction-by-hash This example demonstrates the JSON-RPC request payload for the `eth_getTransactionByHash` method. Ensure the transaction hash is correctly formatted. ```json { "jsonrpc": "2.0", "method": "eth_getTransactionByHash", "params": [ "0x33c3321b162edac1fdbb53af2962b2940c07e334a4f5ff758f1d5ef1235e55d0" ], "id": 1 } ``` -------------------------------- ### Example Authorization Header Source: https://docs.chainstack.com/reference/chainstack-platform-api-delete-node This example demonstrates how to format the Authorization header for API requests, including the 'Bearer' prefix and your secret API key. ```bash curl -X GET 'https://api.chainstack.com/v1/organization/' \ --header 'Authorization: Bearer FX7CWlLg.FMpAO8cgCX2N7s41EncRru2nb5CmTZUt' ``` -------------------------------- ### Get Transaction Receipt with viem Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-transaction-receipt Use the viem library in TypeScript to get a transaction receipt. This example requires you to provide your Chainstack endpoint to the http transport. ```typescript import { createPublicClient, http } from "viem"; const client = createPublicClient({ transport: http("YOUR_CHAINSTACK_ENDPOINT"), }); const receipt = await client.getTransactionReceipt({ hash: "0x33c3321b162edac1fdbb53af2962b2940c07e334a4f5ff758f1d5ef1235e55d0", }); console.log(receipt); ``` -------------------------------- ### Get Organization Info with Specific Token Source: https://docs.chainstack.com/reference/chainstack-platform-api-get-organizaton-info Example of a cURL request to get organization info, demonstrating the use of a specific Bearer token in the Authorization header. ```bash curl -X GET 'https://api.chainstack.com/v1/organization/' \ --header 'Authorization: Bearer FX7CWlLg.FMpAO8cgCX2N7s41EncRru2nb5CmTZUt' ``` -------------------------------- ### Get Transaction Count with web3.py Source: https://docs.chainstack.com/reference/tempo-eth-getblocktransactioncountbynumber This example demonstrates how to get the transaction count for a block using web3.py. It shows both direct provider requests and the web3.py convenience method. ```python from web3 import Web3 node_url = "CHAINSTACK_NODE_URL" web3 = Web3(Web3.HTTPProvider(node_url)) # Get transaction count for latest block result = web3.provider.make_request("eth_getBlockTransactionCountByNumber", ["latest"]) count = int(result['result'], 16) print(f"Latest block: {count} transactions") # Using web3.py method count = web3.eth.get_block_transaction_count('latest') print(f"Latest block (via web3.py): {count} transactions") ``` -------------------------------- ### Spot/Perp Transfer Request Example Source: https://docs.chainstack.com/reference/hyperliquid-exchange-spot-perp-transfer This example shows the parameters required for a Spot/Perp transfer. Ensure the signatureChainId, amount, and nonce are correctly set. ```yaml hyperliquidChain: Mainnet signatureChainId: '0xa4b1' amount: '250.0' toPerp: true nonce: 1705234567890 signature: r: >- 0x0000000000000000000000000000000000000000000000000000000000000000 s: >- 0x0000000000000000000000000000000000000000000000000000000000000000 v: 27 vaultAddress: null ``` -------------------------------- ### eth_getTransactionCount Request Example Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-transaction-count This example demonstrates how to construct a JSON-RPC request to get the transaction count for a specific address. Ensure the address and block parameter are correctly specified. ```json { "jsonrpc": "2.0", "method": "eth_getTransactionCount", "params": [ "0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA", "latest" ], "id": 1 } ``` -------------------------------- ### ETH Transfer Example (ethers.js) Source: https://docs.chainstack.com/reference/ethereum-sendrawtransaction Demonstrates how to perform an ETH transfer on the Sepolia testnet using ethers.js. This example shows how to estimate gas, set up the transaction object, sign it with a private key, and send the raw transaction. ```javascript ethers.js const ethers = require('ethers'); const NODE_URL = "CHAINSTACK_NODE_URL"; const provider = new ethers.JsonRpcProvider(NODE_URL); async function sendEth(value) { // Define the sender and receiver addresses, and the private key const sender = '0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a'; const receiver = '0xe9ba4b4d84d7a3c80245514213b88d50ed937114'; const privateKey = '1111111111111111111111111111111111111111111111111111111111111111'; // Define the gas limit const gasLimit = await provider.estimateGas({ from: sender, to: receiver, value: ethers.parseEther(value), }); // Get the transaction count for the sender address const nonce = await provider.getTransactionCount(sender); // Define the transaction object const transactionObject = { to: receiver, gasPrice: ethers.parseUnits('50', 'gwei'), gasLimit: gasLimit.toString(), nonce: nonce, value: ethers.parseEther(value), }; // Sign the transaction using the private key const wallet = new ethers.Wallet(privateKey, provider); console.log(`Sending transaction...`) const transaction = await wallet.sendTransaction(transactionObject); console.log('Transaction hash:', transaction.hash); } sendEth("2"); ``` -------------------------------- ### gettxoutsetinfo OpenAPI Example Source: https://docs.chainstack.com/reference/bitcoin-gettxoutsetinfo This is an API example for gettxoutsetinfo, a method to get statistics about the unspent transaction output set. This method may take a couple of minutes to complete. ```yaml openapi: 3.0.0 info: title: gettxoutsetinfo example version: 1.0.0 description: >- This is an API example for gettxoutsetinfo, a method to get statistics about the unspent transaction output set. servers: - url: https://nd-20-842-353.p2pify.com security: [] paths: /788f110831fe13808302bd79796d55e8: post: tags: - Blockchain Operations summary: gettxoutsetinfo operationId: getTxOutsetInfo requestBody: required: true content: application/json: schema: type: object properties: jsonrpc: type: string default: '1.0' method: type: string default: gettxoutsetinfo params: {} id: type: integer default: 1 responses: '200': description: Statistics about the unspent transaction output set content: application/json: schema: type: object properties: result: type: object description: Statistics about the unspent transaction output set error: type: object id: type: integer ``` -------------------------------- ### Get Hyperliquid EVM Client Version with ethers.js Source: https://docs.chainstack.com/reference/hyperliquid-evm-web3-client-version This JavaScript example demonstrates how to get the client version using ethers.js. Remember to substitute 'YOUR_CHAINSTACK_ENDPOINT' with your specific Chainstack endpoint. ```javascript import { JsonRpcProvider } from "ethers"; const provider = new JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT"); const clientVersion = await provider.send("web3_clientVersion", []); console.log(clientVersion); ``` -------------------------------- ### Python SDK for Borrow/Lend Supply Action Source: https://docs.chainstack.com/reference/hyperliquid-exchange-borrow-lend This Python example demonstrates how to construct and send a borrow/lend supply action using the hyperliquid-python-sdk. Note that a direct helper for borrowLend is not yet available, so actions are built and signed manually. ```python # Note: the official hyperliquid-python-sdk does not expose a borrowLend helper # yet, so build and post the signed action directly. from hyperliquid.exchange import Exchange from hyperliquid.utils import constants from hyperliquid.utils.signing import sign_l1_action, get_timestamp_ms import eth_account # Public Hyperliquid mainnet endpoint wallet = eth_account.Account.from_key("0x...") # your private key exchange = Exchange(wallet, constants.MAINNET_API_URL) timestamp = get_timestamp_ms() action = {"type": "borrowLend", "operation": "supply", "token": 0, "amount": "1"} signature = sign_l1_action( wallet, action, None, # vault_address timestamp, None, # expires_after exchange.base_url == constants.MAINNET_API_URL, ) result = exchange._post_action(action, signature, timestamp) print(result) ``` -------------------------------- ### Get Block Header by Number using ethers.js Source: https://docs.chainstack.com/reference/hyperliquid-evm-erigon-get-header-by-number This JavaScript example shows how to get a block header by number with ethers.js. Replace 'YOUR_CHAINSTACK_ENDPOINT' with your specific Chainstack node endpoint. ```javascript import { JsonRpcProvider } from "ethers"; const provider = new JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT"); const header = await provider.send("erigon_getHeaderByNumber", [1000]); console.log(header); ``` -------------------------------- ### Sepolia Faucet Request Example Source: https://docs.chainstack.com/reference/chainstack-platform-api-faucet-sepolia This example shows how to request Sepolia testnet ETH by POSTing to the /v1/faucet/sepolia endpoint with a destination wallet address. ```yaml openapi: 3.0.3 info: x-logo: url: https://chainstack.com/assets/docs/api-docs-logo.svg backgroundColor: '#F5F8FC' altText: Chainstack title: 💙 CHAINSTACK PLATFORM API version: v1 contact: name: API Support email: support@chainstack.com description: > A set of API endpoints to operate and manage the platform resources.
See also a [quick API tutorial](https://docs.chainstack.com/reference/quick-tutorial). servers: - url: https://api.chainstack.com description: API endpoint security: [] paths: /v1/faucet/sepolia: post: tags: - Faucet summary: Sepolia Faucet description: Request test tokens. operationId: sepoliaGoerli requestBody: content: application/json: schema: $ref: '#/components/schemas/FaucetSepoliaRequest' examples: value: value: address: '0x1111111111111111111111111111111111111111' required: true responses: '200': description: '' content: application/json: schema: $ref: '#/components/schemas/FaucetSepoliaResponse' examples: value: value: amountSent: 500000000000000000 transaction: >- https://sepolia.etherscan.io/tx/0x1111111111111111111111111111111111111111111111111111111111111111 '400': $ref: '#/components/responses/ValidationError' '429': $ref: '#/components/responses/TooManyRequestsError' security: - APIKeyAuthentication: [] components: schemas: FaucetSepoliaRequest: type: object properties: address: type: string description: Address to send tokens to. FaucetSepoliaResponse: type: object properties: amountSent: type: number description: Amount of tokens sent. transaction: type: string description: Transaction details URL. responses: ValidationError: description: Validation error. content: application/json: schema: type: object properties: error: type: object properties: code: type: string description: A string indicating the kind of error. message: type: string description: A human-readable description of the error. fields: type: object additionalProperties: type: array items: type: string description: Optional. Field-level validation errors. TooManyRequestsError: description: Validation error. content: application/json: schema: type: object properties: error: type: object properties: code: type: string description: A string indicating the kind of error. message: type: string description: A human-readable description of the error. nextFaucetAvailable: type: string description: The date when tokens can be requested next time. securitySchemes: APIKeyAuthentication: type: http scheme: bearer description: > Chainstack API uses [API keys](https://docs.chainstack.com/reference/platform-api-getting-started) to authenticate requests. You can view and manage your API keys in the platform UI. Your API keys carry many privileges, so be sure to keep them secure! Provide your API key as the `Authorization` header. The value of the header consists of `Bearer` prefix and secret key generated through the platform UI. ```bash curl -X GET 'https://api.chainstack.com/v1/organization/' \ --header 'Authorization: Bearer FX7CWlLg.FMpAO8cgCX2N7s41EncRru2nb5CmTZUt' ``` All API requests must be made over HTTPS. ``` -------------------------------- ### Get Storage Value with web3.py Source: https://docs.chainstack.com/reference/avalanche-getstorageat This example shows how to get a storage value from an address and slot using web3.py. Replace 'CHAINSTACK_NODE_URL' with your actual node endpoint and specify the desired block. ```python from web3 import Web3 node_url = "CHAINSTACK_NODE_URL" storage = web3.eth.get_storage_at("0xd5D517aBE5cF79B7e95eC98dB0f0277788aFF634", 0, "latest") print(web3.to_hex(storage)) ``` -------------------------------- ### web3.py Example Source: https://docs.chainstack.com/reference/gettransactionbyblocknumberandindex Example of how to use eth_getTransactionByBlockNumberAndIndex with web3.py. ```APIDOC ## `eth_getTransactionByBlockNumberAndIndex` with web3.py ### Description Retrieves a transaction from a specific block number and index using web3.py. ### Method `web3.eth.get_transaction_by_block(block_number, transaction_index)` ### Parameters - **block_number** (integer or string) - The block number (e.g., 13766424, or a hex string like '0xd20ec4'). - **transaction_index** (integer or string) - The transaction index within the block (e.g., 3, or a hex string like '0x3'). ### Request Example ```python from web3 import Web3 node_url = "CHAINSTACK_NODE_URL" web3 = Web3(Web3.HTTPProvider(node_url)) print(web3.eth.get_transaction_by_block(13766424, 3)) # Hex encoded parameters starting with "0x" are accepted as well. ``` ``` -------------------------------- ### Fetch 50 blocks and uninstall filter using ethers.js Source: https://docs.chainstack.com/reference/arbitrum-uninstallfilter This example shows how to create a block filter, fetch a specific number of new blocks, and then uninstall the filter to conserve resources. It includes error handling and a delay for polling. ```javascript const ethers = require('ethers'); const NODE_URL = "CHAINSTACK_NODE_URL"; const provider = new ethers.JsonRpcProvider(NODE_URL); const BLOCKS_TO_FETCH = 50; const BLOCK_FETCH_INTERVAL_MS = 200; async function getNewBlocks() { const filterId = await provider.send("eth_newBlockFilter", []); let blocks = []; while (blocks.length < BLOCKS_TO_FETCH) { const changes = await provider.send("eth_getFilterChanges", [filterId]); //console.log(changes) // show the changes if (changes.length === 0) { await new Promise(resolve => setTimeout(resolve, BLOCK_FETCH_INTERVAL_MS)); // wait for new blocks } else { blocks = blocks.concat(changes); } } const removeFilter = await provider.send("eth_uninstallFilter", [filterId]); // clean up filter if (removeFilter) { console.log(`We got 50 blocks, filter ${filterId} was removed.`) return blocks } } async function main() { const fiftyBlocks = await getNewBlocks(); console.log(fiftyBlocks) } main() ``` -------------------------------- ### Get Transaction By Hash Response Example Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-transaction-by-hash This example shows a successful response from the `eth_getTransactionByHash` method, detailing the transaction's properties. The `result` object contains comprehensive transaction data. ```json { "jsonrpc": "2.0", "id": 1, "result": { "hash": "0x33c3321b162edac1fdbb53af2962b2940c07e334a4f5ff758f1d5ef1235e55d0", "nonce": "0x1", "blockHash": "0x...", "blockNumber": "0x...", "transactionIndex": "0x...", "from": "0x...", "to": "0x...", "value": "0x...", "gas": "0x...", "gasPrice": "0x...", "input": "0x...", "v": "0x...", "r": "0x...", "s": "0x...", "type": "0x..." } } ``` -------------------------------- ### Example JSON-RPC Request and Response Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-transaction-by-block-hash-and-index This example demonstrates the structure of a JSON-RPC request to get a transaction by block hash and index, along with a sample response containing detailed transaction information. ```json { "jsonrpc": "2.0", "id": 1, "result": { "hash": >- "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "nonce": "0x1", "blockHash": >- "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a", "blockNumber": "0x9d0c37", "transactionIndex": "0x0", "from": "0xFC1286EeddF81d6955eDAd5C8D99B8Aa32F3D2AA", "to": "0x5555555555555555555555555555555555555555", "value": "0xde0b6b3a7640000", "gas": "0x5208", "gasPrice": "0x3b9aca00", "input": "0x", "v": "0x1c", "r": >- "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "s": >- "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890", "type": "0x0" } } ``` -------------------------------- ### Usage Examples for System Transaction Analysis Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-system-txs-by-block-hash Demonstrates how to use the `analyzeSystemTransactions` function with a sample block hash and logs the analysis results or any errors encountered. ```javascript // Usage examples const blockHash = "0x1970d9c7ce6f00a982b421610ad400a79522c102a26db24ef3ec1f2bd621c399"; analyzeSystemTransactions(blockHash) .then(analysis => console.log('System Transaction Analysis:', analysis)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Get Peer Count with web3.py Source: https://docs.chainstack.com/reference/bnb-peercount This Python snippet demonstrates how to get the number of connected peers using the web3.py library. Replace 'CHAINSTACK_NODE_URL' with your node's URL and ensure web3.py is installed. ```python from web3 import Web3 node_url = "CHAINSTACK_NODE_URL" web3 = Web3.HTTPProvider(node_url) peers = web3.provider.make_request('net_peerCount', []) print(peers) ``` -------------------------------- ### Send USD using hyperliquid-python-sdk Source: https://docs.chainstack.com/reference/hyperliquid-exchange-usd-send Python example using the hyperliquid-python-sdk to send USD. Requires initialization with an account and API URL. ```python from hyperliquid.exchange import Exchange from hyperliquid.utils import constants import eth_account # Initialize with your private key account = eth_account.Account.from_key("0x...") exchange = Exchange(account, constants.MAINNET_API_URL) # Send 100.5 USDC to another address transfer_result = exchange.usd_transfer( amount=100.5, destination="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0", ) print(transfer_result) ``` -------------------------------- ### Place Limit Buy Order (Python SDK) Source: https://docs.chainstack.com/reference/hyperliquid-exchange-place-order Demonstrates placing a limit buy order for BTC using the hyperliquid-python-sdk. Initializes the Exchange client with an account and the mainnet API URL. ```python from hyperliquid.exchange import Exchange from hyperliquid.utils import constants import eth_account # Initialize with your private key. The public mainnet API is used # because this signing endpoint is not served through Chainstack. account = eth_account.Account.from_key("0x...") exchange = Exchange(account, constants.MAINNET_API_URL) # Place a limit buy order for BTC. order_result = exchange.order( name="BTC", is_buy=True, sz=0.01, limit_px=50000, order_type={"limit": {"tif": "Gtc"}}, reduce_only=False, ) print(order_result) ``` -------------------------------- ### ethers.js Example to Get Uncle by Block Hash Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-get-uncle-by-block-hash-and-index This JavaScript example uses ethers.js to retrieve an uncle block by its hash and index. Remember to substitute YOUR_CHAINSTACK_ENDPOINT with your actual Hyperliquid node endpoint. ```javascript import { JsonRpcProvider } from "ethers"; const provider = new JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT"); const blockHash = "0x2ce91ae0ed242b4b78b432a45b982fb81a414d6b04167762ed3c7446710a4b8e"; const uncle = await provider.send("eth_getUncleByBlockHashAndIndex", [ blockHash, "0x0", ]); console.log(uncle); ``` -------------------------------- ### web3.py Example Source: https://docs.chainstack.com/reference/gettransactionbyblockhashandindex Example of how to use `eth_getTransactionByBlockHashAndIndex` with web3.py. ```APIDOC ## `eth_getTransactionByBlockHashAndIndex` (web3.py) ### Description Retrieves a transaction from a specific block by its hash and index using web3.py. ### Method `web3.eth.get_transaction_by_block(block_hash, transaction_index)` ### Parameters - **block_hash** (string) - Required - The hash of the block. - **transaction_index** (integer) - Required - The index of the transaction within the block. ### Request Example ```python from web3 import Web3 node_url = "CHAINSTACK_NODE_URL" web3 = Web3(Web3.HTTPProvider(node_url)) print(web3.eth.get_transaction_by_block("0x84fcbb099d339793e0271db167c937723202a25672a676a2066268fff6d0e945", 1)) ``` ### Response #### Success Response (200) - **transaction** (object) - An object containing the transaction details. ``` -------------------------------- ### User Funding Request Example Source: https://docs.chainstack.com/reference/hyperliquid-info-user-funding This example demonstrates how to structure a request to retrieve user funding history. Ensure the 'type' is set to 'userFunding' and provide the user's address and a start time. ```json { "type": "userFunding", "user": "0x2ba553d9f990a3b66b03b2dc0d030dfc1c061036", "startTime": 1681923833000, "endTime": 1681924833000 } ``` -------------------------------- ### TON v3 Get Wallet Information OpenAPI Specification Source: https://docs.chainstack.com/reference/ton-wallet-v3 This OpenAPI specification defines the GET /api/v3/walletInformation endpoint for retrieving details about a TON wallet. It includes parameters, response schemas, and example values. ```yaml openapi: 3.0.0 info: title: TON API version: 3.0.0 description: API for interacting with The Open Network (TON) blockchain servers: - url: >- https://ton-mainnet.core.chainstack.com/f2a2411bce1e54a2658f2710cd7969c3/api/v3 security: [] paths: /api/v3/walletInformation: get: tags: - Wallet summary: Get Wallet Information description: Retrieves information about a specific wallet on the TON blockchain operationId: getWalletInfo parameters: - name: address in: query description: The address of the wallet to retrieve information for required: true schema: type: string default: 0QAvTjjA5ZBbHN3a-SYnO1qvzlgNx09OC2bhYBPAbfs3S6q7 example: 0QAvTjjA5ZBbHN3a-SYnO1qvzlgNx09OC2bhYBPAbfs3S6q7 responses: '200': description: Successful response content: application/json: schema: type: object properties: wallet: type: boolean description: Indicates if the address is a wallet balance: type: string description: The balance of the wallet in nanotons account_state: type: string description: The state of the account (e.g., active, uninitialized) wallet_type: type: string description: The type of the wallet contract seqno: type: integer description: The current sequence number of the wallet last_transaction_lt: type: string description: The logical time of the last transaction last_transaction_hash: type: string description: The hash of the last transaction ``` -------------------------------- ### Create Sub-Account using TypeScript SDK Source: https://docs.chainstack.com/reference/hyperliquid-exchange-create-sub-account This TypeScript example shows how to create a sub-account using the @nktkas/hyperliquid package. Ensure your wallet is loaded securely and the transport is configured correctly. ```typescript import * as hl from "@nktkas/hyperliquid"; import { privateKeyToAccount } from "viem/accounts"; // Load your wallet from a private key (use a secure source in production) const wallet = privateKeyToAccount("0x..."); // Default transport targets the public Hyperliquid mainnet API const transport = new hl.HttpTransport(); const client = new hl.ExchangeClient({ transport, wallet }); // Create a sub-account under your main account const result = await client.createSubAccount({ name: "my-sub-account" }); console.log(result); ``` -------------------------------- ### Basic eth_unsubscribe usage with wscat Source: https://docs.chainstack.com/reference/hyperliquid-evm-eth-unsubscribe Demonstrates how to create a subscription using `eth_subscribe` and then unsubscribe from it using `eth_unsubscribe` with the obtained subscription ID via `wscat`. Ensure you have a WebSocket connection established first. ```shell $ wscat -c wss://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm # Wait for the connection to be established Connected (press CTRL+C to quit) # First create a subscription > {"id":1,"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"]} < {"jsonrpc":"2.0","id":1,"result":"0x1234567890abcdef"} # Now unsubscribe using the subscription ID > {"id":2,"jsonrpc":"2.0","method":"eth_unsubscribe","params":["0x1234567890abcdef"]} < {"jsonrpc":"2.0","id":2,"result":true} ``` -------------------------------- ### Get txpool_status with ethers.js Source: https://docs.chainstack.com/reference/tempo-txpool-status Use this snippet to get the pending and queued transaction counts from the Tempo transaction pool using ethers.js. Ensure you have the ethers.js library installed and a valid Chainstack node URL. ```javascript const ethers = require('ethers'); const NODE_URL = "CHAINSTACK_NODE_URL"; const provider = new ethers.JsonRpcProvider(NODE_URL); const getTxpoolStatus = async () => { const status = await provider.send("txpool_status", []); console.log(`Pending: ${parseInt(status.pending, 16)}`); console.log(`Queued: ${parseInt(status.queued, 16)}`); }; getTxpoolStatus(); ```