Pharos 백서

Pharos

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 18쪽 중 5쪽

ferred framework (Foundry, Hardhat) for a smoother workflow ## Next Steps * Verify your deployed contracts * Use the explorer to debug and monitor transactions * Combine with RPC and indexing tools for deeper insights # RPC Infrastructure ## Overview RPC endpoints are the primary way your application interacts with the Pharos Network. They allow you to send transactions, query on-chain data, and communicate with the network programmatically. As a developer, you’ll use RPCs to connect your frontend, backend, or scripts to the blockchain during development and in production. ## What You Can Do with RPC * Send transactions to the network * Read on-chain data (balances, contract state, logs) * Interact with smart contracts * Listen to events and track activity * Power applications, scripts, and integrations ## Why It Matters RPC endpoints act as the bridge between your application and the blockchain. Choosing the right provider and configuration is important for performance, reliability, and scalability. ## Available RPC Providers Pharos supports multiple RPC providers for both Mainnet and Testnet environments. * ZAN RPC * Nirvana RPC * Alchemy RPC # ZAN RPC ZAN Node offers stable and fast RPC connections to Pharos Network, while providing a range of enhanced capabilities to data retrieval API and dynamic monitoring of smart contracts and assets. ## How to Access Pharos Testnet RPC from ZAN? ### Step 1: Create a ZAN account A ZAN account is required if you want to create an API key on the ZAN platform for configuring an RPC node service on Pharos. For more information, see [Preparing a ZAN account](https://docs.zan.top/docs/quick-start-guide#-preparing-a-zan-account). ### Step 2: Create the API key required for configuring RPC Service on Pharos Network If you want to configure the RPC node service network, you need to create an API key on the ZAN platform. This key is used for verification during node connection. You [can create the API key on the ZAN platform](https://docs.zan.top/docs/quick-start-guide#-creating-your-api-key-on-the-zan-platform). After the API key is created, you can get the URLs for the Pharos Network. ### Step 3: Copy your network URL After the API key is created, you can get the URLs that can be used for accessing Pharos Network. Search for Pharos in the Chain RPC section. Click Copy to the right of the HTTPS URL to quickly copy the URL. <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeS_l7R2_PVVOMygh4Hy0Z8jNmeG1ZIsubVgkttcuOgfSbSTCrrFG60fX2SlbWSjI5EPGPGzlsE0HYoZ1trmuhtprjUkM6rvU_xNQfhYAQzH8sB42NWgE6T2OpP-8uwTT-57dWRzw?key=gOwVsY2HEJ_jkvNt_voFYQ" alt=""><figcaption></figcaption></figure> ### For Example: | Network | HTTPS URL | WSS URL | | ---------------- | -------------------------------------------------------- | ------------------------------------------------------- | | Atlantic Testnet | <https://api.zan.top/node/v1/pharos/testnet/{apikey}> | wss\://api.zan.top/node/ws/v1/pharos/testnet/{apikey} | | Pacific Mainnet | <https://api.zan.top/node/v1/pharos/mainnet/{api\\_key}> | wss\://api.zan.top/node/ws/v1/pharos/mainnet/{api\_key} | ### Video Reference: [Pharos RPC.mp4](https://drive.google.com/file/d/1fMDF24yQu3xtnqQCOyQc9141Regfe1Ak/view?usp=sharing) # Alchemy RPC ## Overview Alchemy provides scalable RPC infrastructure and developer tooling for interacting with blockchain networks. On Pharos, Alchemy can be used to access reliable RPC endpoints for both Pacific Mainnet and Atlantic Testnet, making it suitable for application development and production use. ## Getting Started with Alchemy To use Alchemy with Pharos, you’ll need to [create an Alchemy account](https://dashboard.alchemy.com/signup?utm_source=docs\&utm_medium=referral\&utm_content=reference_pharos-api-quickstart) and generate an API key. Here are some prerequisites before you start interacting: 1. Sign up or log in to Alchemy 2. Create a new app 3. Select the Pharos network 4. Generate your API key Once done, the API key will let you interact with the Pharos network through a set of JSON-RPC methods. Follow the guide below to start interacting with Pharos. ### Step 1. Choose a package manager (npm or yarn) Choose between `npm` and `yarn` based on your preference or project requirements. {% tabs %} {% tab title="npm" %} ``` # Begin with npm by following the npm documentation # https://docs.npmjs.com/downloading-and-installing-node-js-and-npm ``` {% endtab %} {% tab title="yarn" %} ``` # For yarn, refer to yarn's installation guide # https://classic.yarnpkg.com/lang/en/docs/install ``` {% endtab %} {% endtabs %} ### Step 2. Set up your project Run the following commands to create and initialize your project: {% tabs %} {% tab title="npm" %} ``` $ mkdir pharos-api-quickstart $ cd pharos-api-quickstart $ npm init --yes ``` {% endtab %} {% tab title="yarn" %} ``` $ mkdir pharos-api-quickstart $ cd pharos-api-quickstart $ yarn init --yes ``` {% endtab %} {% endtabs %} This creates a new directory named `pharos-api-quickstart` and initializes a Node.js project within it. ### Step 3. Make your first request Install Axios, a popular HTTP client, to make API requests: {% tabs %} {% tab title="npm" %} ``` $ npm install axios ``` {% endtab %} {% tab title="yarn" %} ``` $ yarn add axios ``` {% endtab %} {% endtabs %} Create an `index.js` file in your project directory and paste the following code: ```javascript const axios = require('axios'); const url = 'https://pharos-mainnet.g.alchemy.com/v2/your-api-key'; const payload = { jsonrpc: '2.0', id: 1, method: 'eth_blockNumber', params: [] ``` Replace `your-api-key` with your actual Alchemy API key from the [Alchemy Dashboard](https://dashboard.alchemy.com/signup?utm_source=docs\&utm_medium=referral\&utm_content=reference_pharos-api-quickstart) ### Step 4. Run your script Run your script to make a request to the network: ```shell $ node index.js ``` You should see the latest block information from Pharos's network outputted to your console: ```shell $ Latest Block: 0x... ``` ## Next Steps You've made your first request to the Pharos using Alchemy API. You can now explore the various [JSON-RPC methods](/api-and-sdk/json-rpc-methods) available on Pharos and start building your dApps. # Nirvana RPC ## Overview Nirvana Labs provides enterprise-grade blockchain infrastructure, including high-performance RPC nodes and dedicated node services. On Pharos, Nirvana RPC can be used to power applications that require reliable network access, low latency, and scalable infrastructure. ## When to Use Nirvana RPC Nirvana RPC is well-suited for: * Production applications requiring stable and consistent RPC access * Backend services and APIs handling high request volumes * Use cases where performance and reliability are critical * Teams that may need dedicated or scalable node infrastructure ## Access Developers building on Pharos can access Nirvana RPC endpoints by requesting API keys through the Pharos team. * **Access Type:** Dev API Key (unrestricted RPC access) * **Request:** Contact the Pharos team to obtain credentials (Reach out on mail: <janesh@pharos.xyz> or tg: @janesh\_dani) ## Documentation For more details on Nirvana Labs infrastructure and capabilities: <https://nirvanalabs.io/product#rpc-nodes> # Pharos MCP ## Overview The Pharos MCP server brings Pharos chain data and onchain operations into any client that speaks the [Model Context Protocol](https://modelcontextprotocol.io) — Claude Desktop, Cursor, Windsurf, Codex, and custom agent runners. Instead of writing RPC plumbing, you ask your AI assistant in plain language — *"what's the latest Pharos block?"*, *"check the PROS balance of 0x…"* — and it calls the right chain method for you. | | | | ------------------- | ---------------------------------------------------------------------------------- | | **Hosted endpoint** | `https://mcp.pharos.xyz/mcp` | | **Transport** | Streamable HTTP | | **Authentication** | None — public | | **Rate limit** | 120 requests per minute per IP | | **Chain ID** | `1672` (`0x688`) | | **Native token** | PROS | | **Source** | [github.com/PharosNetwork/pharos-mcp](https://github.com/PharosNetwork/pharos-mcp) | ## Quick Start Add the server to your MCP client configuration: ```json { "mcpServers": { "pharos": { "type": "http", "url": "https://mcp.pharos.xyz/mcp" } } } ``` No API key is required. ### Clients that only support stdio Some clients cannot connect to remote MCP servers directly. Bridge to the hosted endpoint with [`mcp-remote`](https://www.npmjs.com/package/mcp-remote): ```json { "mcpServers": { "pharos": { "command": "npx", "args": ["-y", "mcp-remote", "https://mcp.pharos.xyz/mcp"] } } } ``` ### Verify the connection ```bash curl https://mcp.pharos.xyz/health ``` ```json {"status":"ok","chain":"Pharos","chainId":1672,"rpcUrl":"https://rpc.pharos.xyz"} ``` ## Available Tools ### Chain and block data | Tool | JSON-RPC method | Description | | ------------------ | ------------------------------------------------------ | ----------------------------------------- | | `get_chain_info` | `eth_chainId`, `eth_blockNumber`, `web3_clientVersion` | Chain ID, client version and latest block | | `get_block_number` | `eth_blockNumber` | Latest block height | | `get_block` | `eth_getBlockByNumber` | Block by tag or number | | `get_gas_price` | `eth_gasPrice`, `eth_maxPriorityFeePerGas` | Current gas price and priority fee | ### Accounts and transactions | Tool | JSON-RPC method | Description | | ------------------------- | --------------------------- | --------------------------------- | | `get_balance` | `eth_getBalance` | Native PROS balance of an address | | `get_transaction_count` | `eth_getTransactionCount` | Address nonce | | `get_transaction` | `eth_getTransactionByHash` | Transaction by hash | | `get_transaction_receipt` | `eth_getTransactionReceipt` | Transaction receipt | ### Contracts | Tool | JSON-RPC method | Description | | ---------------- | ------------------ | ------------------------------------- | | `eth_call` | `eth_call` | Read-only contract call | | `estimate_gas` | `eth_estimateGas` | Estimate gas without sending | | `get_code` | `eth_getCode` | Contract bytecode | | `get_storage_at` | `eth_getStorageAt` | Read a contract storage slot | | `get_logs` | `eth_getLogs` | Event logs (max 1000 blocks per call) | ### Broadcasting | Tool | JSON-RPC method | Description | | ---------------------- | ------------------------ | --------------------------------------- | | `send_raw_transaction` | `eth_sendRawTransaction` | Broadcast an already-signed transaction | ## Block Parameters Tools that accept a `block` parameter take any of: * A named tag: `latest`, `earliest`, `pending`, `safe`, `finalized` * A decimal number: `13005874` * A hex quantity: `0xc67432` Omitting it defaults to `latest`. ## Querying Event Logs `get_logs` is capped at **1000 blocks per call**, matching the upstream RPC limit. Requests spanning a wider range are rejected with a message telling you the requested size and the maximum, so page through larger ranges in 1000-block windows. Narrow results with `address` and `topics` wherever possible — an unfiltered query over a wide range is slow for everyone. ## Sending Transactions The server is **non-custodial**: it never receives, stores, or asks for a private key. Signing happens entirely in your own wallet or script; the server only relays the resulting signed bytes to the network. ``` Your private key ──sign (locally)──▶ 0x02f86b…──▶ MCP server ──▶ Pharos ``` The flow is: 1. Build and sign a transaction locally with your own tooling (viem, ethers, a wallet). 2. Pass the resulting `0x`-prefixed string to `send_raw_transaction`. 3. Use the returned transaction hash with `get_transaction_receipt` to confirm inclusion. Because signing is local, an AI agent connected to this server can prepare and broadcast a transaction for you without ever having access to your key. ## Self-Hosting Run your own instance when you need a private RPC provider, a higher rate limit, or your own operational control. Requires Node.js 20 or newer. ```bash git clone https://github.com/PharosNetwork/pharos-mcp.git cd pharos-mcp npm install npm run build npm start ``` ### Connecting a local instance over stdio ```json { "mcpServers": { "pharos": { "command": "node", "args": ["/absolute/path/to/pharos-mcp/dist/src/index.js"], "env": { "PHAROS_RPC_URL": "https://rpc.pharos.xyz", "PHAROS_CHAIN_ID": "1672", "PHAROS_NATIVE_SYMBOL": "PROS" } } } } ``` ### Using your own RPC endpoint Point `PHAROS_RPC_URL` at any Pharos RPC — including a provider endpoint that carries an API key, or your own node: ```json "env": { "PHAROS_RPC_URL": "https://your-provider.example/v2/YOUR_API_KEY" } ``` Keep such a URL out of version control; it holds a credential. ### Docker ```bash docker build -t pharos-mcp-server . docker run -p 3001:3001 \ -e MCP_TRANSPORT=http \ -e MCP_HOST=0.0.0.0 \ pharos-mcp-server ``` ### Configuration | Variable | Default | Description | | ----------------------------- | ------------------------ | ------------------------------------------------------------------------------------ | | `PHAROS_RPC_URL` | `https://rpc.pharos.xyz` | Upstream JSON-RPC endpoint | | `PHAROS_CHAIN_ID` | `1672` | Expected chain ID | | `PHAROS_NATIVE_SYMBOL` | `PROS` | Native token symbol | | `MCP_TRANSPORT` | `stdio` | `stdio` or `http` | | `MCP_HOST` | `127.0.0.1` | Bind address; use `0.0.0.0` in containers | | `MCP_PORT` | `3001` | HTTP port | | `MCP_AUTH_TOKEN` | — | Bearer token; authentication is off when unset | | `ENABLE_SEND_RAW_TRANSACTION` | `false` | Enable transaction broadcasting | | `RATE_LIMIT_PER_MINUTE` | `120` | Per-IP request cap; `0` disables | | `TRUST_PROXY` | `false` | Set `true` behind exactly one trusted proxy so rate limiting sees the real client IP | | `MAX_SESSIONS` | `500` | Maximum concurrent sessions; further sessions get `503` | | `SESSION_TIMEOUT_MINUTES` | `30` | Idle session eviction time | ## Security Notes * The server has no use for a private key or mnemonic — never pass one to it. * `send_raw_transaction` is disabled by default in self-hosted deployments. If you enable it on a publicly reachable instance, put authentication in front of it first; an open broadcast endpoint lets anyone push transactions through your node. * Set `MCP_AUTH_TOKEN` and terminate TLS in front of any instance you expose beyond localhost. * `admin_*`, `debug_*`, `personal_*` and `txpool_*` methods are not exposed. ## Troubleshooting | Symptom | Cause and fix | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | `Unknown MCP session` | The session expired or the server restarted. Reconnect the client — a full client restart clears cached session state. | | `429 Too Many Requests` | Rate limit reached. Back off and retry after the interval in the `Retry-After` header, or self-host for a higher limit. | | `Block range too large` | `get_logs` was called with more than 1000 blocks. Page through the range in smaller windows. | | `Connection failed` | The client may not support remote MCP servers. If it connects but lists no tools, this is the same cause. Bridge with `mcp-remote` as shown above. | # Indexer ## Overview Indexing allows developers to efficiently query and access on-chain data without directly relying on raw RPC calls. Instead of scanning the blockchain for every request, indexing services process and organize data in a way that makes it easier to retrieve, filter, and use within applications. ## What You Can Do with Indexers * Query smart contract data efficiently * Track events and historical activity * Build dashboards and analytics * Power frontend applications with structured data * Monitor protocol and application-level metrics ## Why It Matters While RPC endpoints are useful for direct interaction with the network, they are not optimized for complex queries or large-scale data retrieval. Indexing services solve this by providing faster and more flexible access to blockchain data, making them essential for building scalable applications. ## Available Indexing Providers Pharos supports indexing solutions that help developers access and structure on-chain data efficiently. Refer to the provider below for setup and integration details: * Goldsky # Goldsky Goldsky is a high-performance data indexing provider that makes it easy to extract, transform, and load on-chain data to power both application and analytics use cases. ## Indexing Pharos with Goldsky Goldsky is Web3’s realtime data platform, giving developers access to world-class data infrastructure to power their onchain applications. Seamlessly access the data you need with lightning-fast indexing, resilient subgraphs, and flexible data streaming pipelines. Spend less time on the complexities of infra maintenance and more time building incredible user experiences. ### Why Goldsky? * **Scalable Infrastructure**: Scalable and resilient infrastructure, handling data challenges as your application grows. * **Developer-Friendly Tools**: Easily integrate and iterate without being slowed down by complex data engineering. * Enterprise Support: The Goldsky team is available 24/7 to help if things go wrong. ### Goldsky Products #### Subgraphs **Subgraphs** let you efficiently access blockchain data relevant to your application. * **Fast Queries**: Optimized infrastructure means faster query responses and better performance. * **Flexible Integration**: Customize your queries and adapt indexing to suit your application's unique needs. * **Tagging & Organization**: Use tagging to organize your data, making it easier to manage and access. **Use Cases**: dApps, NFT marketplaces, gaming, DAOs – any scenario where you need reliable, real-time blockchain data. #### Mirror **Mirror** gives you full control over your blockchain data. Instead of just querying, you can stream onchain data directly into your own database. * **Realtime Streaming**: Stream onchain data directly to your existing systems, enabling fast and interactive user experiences. * **Custom Data Handling**: Sync data into your own internal databases and combine it with other onchain or offchain data. * **Automatic Data Updates**: Goldsky ensures that your data stays accurate with continuous synchronization and updates. **Use Cases**: Complex data queries, integration into existing databases, real-time analytics, points systems, leaderboards, user progress tracking, loyalty programs, and custom metrics dashboards. ### Getting Started For more details, check out the [Goldsky Documentation](https://goldsky.com/chains/pharos/?utm_source=pharos\&utm_medium=docs). Start building smarter, faster, and focus on what really matters: delivering a great experience to your users. # Oracle ## Overview Oracles provide access to off-chain data within smart contracts. They enable applications on Pharos to interact with real-world information such as asset prices, market data, and external events. For many use cases, especially in DeFi and real-world asset applications, oracles are a critical component for bringing reliable data on-chain. ## What You Can Do with Oracles * Access price feeds and market data * Build applications that rely on real-world inputs * Trigger contract logic based on external conditions * Power lending, trading, and RWA protocols * Integrate off-chain data into on-chain workflows ## Why It Matters Smart contracts operate in a deterministic on-chain environment and cannot directly access external data. Oracles bridge this gap by securely delivering off-chain data to the blockchain, enabling more advanced and dynamic applications. ## Available Oracle Providers P
프로젝트로 돌아가기