Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.2 KB
Raw Blame
import { createAction, PieceAuth, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { MEMPOOL_API_BASE_URL } from '../../common';

export const getBlockHeight = createAction({
 auth:PieceAuth.None(),
    name: 'get_block_height',
    displayName: 'Get Block Height',
    description: 'Returns the hash of the block currently at specified height',
    audience: 'both',
    aiMetadata: { description: 'Resolve a block height to its block hash. Pick this to translate a numeric height into the hash other block actions need; use Get Block Timestamp to find a block by time, or Get Block Tip Hash for the latest block. Read-only.', idempotent: true },
    // category: 'Blocks',
    props: {
        height: Property.Number({
            displayName: 'Block Height',
            description: 'The height of the block to look up',
            required: true
        })
    },
    async run({ propsValue }) {
        const response = await httpClient.sendRequest({
            method: HttpMethod.GET,
            url: `${MEMPOOL_API_BASE_URL}/api/block-height/${propsValue.height}`,
        });
        return response.body;
    },
});