bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 18쪽 중 18쪽
r.getSupported());
});
// Start server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`✅ Facilitator is running on port: ${PORT}`);
console.log(`⛓️ Supported network: eip155:1672 (Pharos Pacific)`);
});
```
### Skill
**Skill Repository:** `https://github.com/PharosNetwork/examples/tree/main/skills/x402-pharos`
This skill facilitates using the x402 SDK to construct the Pharos x402 server and the corresponding test client. This skill targets the Pharos Pacific Mainnet with chain ID 1672. Configure the USDC token address (`0xc879c018db60520f4355c26ed1a6d572cdac1815`) with the official token contract address you intend to use for payments.
The following demonstrates building a server and client demo using this skill, taking opencode as an example.
**Create Server:** Enter the prompt: "Help me create a pharos-x402 server." It will ask for corresponding parameters (recipient address, Facilitator URL, etc.) and automatically generate the corresponding code files and configuration files.
<figure><img src="https://3298017099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmFp0ycownpuaUNf2xeE%2Fuploads%2Fgit-blob-18768f55bc11344c54eecfe6ba65a61352b8300b%2Fx402-2.png?alt=media" alt="x402-2"><figcaption></figcaption></figure>
During the process, you can ask it to generate simple example code through conversation, including `/data` and `/premium` endpoints.
<figure><img src="https://3298017099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmFp0ycownpuaUNf2xeE%2Fuploads%2Fgit-blob-316bb7964b7d848dd08f0ec19ec2ef0be991ccee%2Fx402-3.png?alt=media" alt="x402-3"><figcaption></figcaption></figure>
The service can then be started.
<figure><img src="https://3298017099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmFp0ycownpuaUNf2xeE%2Fuploads%2Fgit-blob-23fa3541b42f20bb629b881c02251ae8d250c076%2Fx402-4.png?alt=media" alt="x402-4"><figcaption></figcaption></figure>
Next, you can ask it to write a test client.
<figure><img src="https://3298017099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmFp0ycownpuaUNf2xeE%2Fuploads%2Fgit-blob-73535c7cd1afe9b9ae753ed886f82f1e4e1baeb6%2Fx402-5.png?alt=media" alt="x402-5"><figcaption></figcaption></figure>
Once the private key is configured, you can test the payment process.
**Please note: never reveal your private key to large models. Configure it via environment variables or file writing.**
<figure><img src="https://3298017099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNmFp0ycownpuaUNf2xeE%2Fuploads%2Fgit-blob-43d4fce647717e3b77227f533a45447155d31d63%2Fx402-6.png?alt=media" alt="x402-6"><figcaption></figcaption></figure>
## Advantages of x402 on Pharos
| Features | Pharos | Other EVM Chains |
| ----------------------- | -------------- | ----------------------- |
| TPS | 30,000 | Usually < 5,000 |
| Block Time | < 1 Second | Usually 2 - 15 Seconds |
| Finality Time | Sub-second | Usually several minutes |
| Micro-payment Viability | Extremely High | Low - High |
### Why Choose Pharos for x402?
* **Ultra-low transaction costs:** Pharos's high throughput and efficient consensus minimize transaction costs, making micro-payments truly economically viable.
* **Instant Finality:** Sub-second finality means users can access content immediately after payment without waiting for multiple block confirmations.
* **EVM Compatibility:** Fully compatible with Ethereum tools (ethers.js, viem, Hardhat, etc.); existing developers do not need to learn new tools.
* **Compliance-Friendly:** Pharos's built-in compliance modules (ZK-KYC/AML) allow x402 payments to meet regulatory requirements, making it suitable for institutional adoption.
* **Modular Architecture:** Through SPN (Specialized Processing Network), the execution environment can be customized for specific payment scenarios.
## Development Recommendations
* **Temporary Access Authorization based on JWT:** After the user completes payment verification, the server can issue a short-term valid JSON Web Token (JWT) as a credential for subsequent resource access. This token should have a reasonable expiration time to avoid repeated payments while reducing the overhead of frequent on-chain verification by the server.
* **Security Management of Sensitive Information:** All confidential data such as private keys and API keys should be injected into the application through environment variables or dedicated secret management services. Hardcoding them in source code or configuration files is strictly prohibited to prevent accidental leakage.
* **Transaction Idempotency and Retry Support:** The client should be able to initiate a retry request based on the original transaction hash after a network interruption or request failure. The server must implement idempotency processing logic to ensure that the same on-chain transaction is not billed multiple times or granted permissions repeatedly.
* **Introducing Facilitator Service to Decouple Blockchain Interaction:** Design a middleware service (Facilitator) to encapsulate complex logic such as blockchain node communication, transaction listening, and verification, simplifying the main business code. However, note that this component could become a performance bottleneck or a single point of failure; it is recommended to combine redundant deployment, health checks, multi-account strategies, and downgrade policies to improve system resilience.
## Reference Resources
* **Pharos Official Website:** `https://www.pharos.xyz/`
* **Pharos Documentation:** `https://docs.pharos.xyz/`
* **x402 Specification:** `https://x402.org/`
# EVM
The Ethereum Virtual Machine (EVM) is the core component of the Ethereum blockchain, responsible for executing smart contracts and managing the state of the network. It acts as a decentralized computer, maintaining a global state and executing program instructions defined in smart contracts. Key features include:
* **State Machine**: Executes transactions and changes the blockchain state.
* **Deterministic Execution**: Given the same input, it will always produce the same output.
* **Isolated Execution**: Executes code in a sandboxed environment.
**References**:
* [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf): The authoritative technical document that defines the EVM and its operational mechanisms.
### Learning Resources
#### Tutorials and Guides
* **EVM Playground**: An interactive platform for experimenting with EVM opcodes and bytecode. It provides detailed explanations and visualizations of how EVM executes opcodes.
* **Accessing Constant Variables**: Learn how to define and use constant variables in EVM. [Link](https://evm.codes/playground?lesson=1)
* **Function Parameters from Calldata**: Understand how to access function parameters using calldata. [Link](https://evm.codes/playground?lesson=2)
* **Testing Macros in EVM.codes**: Build and test functions using raw EVM bytecode. [Link](https://evm.codes/playground?lesson=3)
* **General EVM Playground**: [Link](https://evm.codes)
**EVM Cheatsheet**: A comprehensive guide detailing EVM architecture, functionalities, and operational mechanisms. It covers:
* EVM Architecture: Stack, memory, storage, and instruction set.
* Bytecode and Opcodes: Detailed explanations of EVM bytecode and commonly used opcodes.
* Memory vs. Storage: Differences and use cases.
* Gas and Gas Management: Understanding gas costs and optimization techniques.
* **Link**: [EVM Cheatsheet](https://github.com/pylaugh/evm-cheatsheet)
#### Academic Research
* **Smart Contract Decompilation**: Learn how to decompile EVM bytecode back into high-level languages like Solidity. Tools like Mythril, Ethersplay, or Porosity are used for this purpose.
* **Mythril**: [Link](https://github.com/ConsenSys/mythril)
* **Ethersplay**: [Link](https://github.com/ConsenSys/ethersplay)
* **Porosity**: [Link](https://github.com/gnidan/porosity)
* **EVM Execution Model**: Explore how EVM executes opcodes, manages memory and storage, and handles transactions.
* **Link**: [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf)
### Tools for EVM Development
* **EVM From Scratch**: A project that guides you through implementing your own EVM in various programming languages. It helps in understanding the core mechanics of EVM.
* **Link**: [EVM From Scratch](https://github.com/w1nt3r-eth/evm-from-scratch)
* **EVM Puzzles**: A collection of interactive puzzles designed to help you practice and understand EVM operations.
* **Link**: [EVM Puzzles](https://github.com/fvictorio/evm-puzzles)
### Community and Discussion
* **EVM Learning Manual**: A curated list of resources for learning EVM, maintained by the blockchain community.
* **Link**: [EVM Learning Manual](https://learnblockchain.cn/article/4800)
* **Stack Overflow**: A platform where you can find answers to common EVM-related questions and participate in discussions.
* **Link**: [Stack Overflow - EVM Tag](https://stackoverflow.com/questions/tagged/evm)
### Practical Examples and Use Cases
* **Contract Address Generation**: Learn how contract addresses are generated using sender address and nonce.
* **Link**: [Contract Address Generation](https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed)
* **Bytecode Decompilation**: Understand the process of converting bytecode into opcodes and reconstructing high-level code.
* **Link**: [Mythril Documentation](https://mythril.readthedocs.io/en/latest/)
* **Storage Management**: Explore how EVM handles storage variables, including writing to and reading from storage slots.
* **Link**: [Solidity Documentation - Storage](https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html)
### References
* **EVM Playground**: <https://evm.codes>
* **EVM Cheatsheet**: <https://github.com/pylaugh/evm-cheatsheet>
* **EVM From Scratch**: <https://github.com/w1nt3r-eth/evm-from-scratch>
* **EVM Puzzles**: <https://github.com/fvictorio/evm-puzzles>
* **EVM Learning Manual**: <https://learnblockchain.cn/article/4800>
* **Stack Overflow - EVM Tag**: <https://stackoverflow.com/questions/tagged/evm>
* **Contract Address Generation**: <https://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed>
* **Mythril Documentation**: <https://mythril.readthedocs.io/en/latest/>
* **Solidity Documentation - Storage**: <https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html>
# Solidity
The official Solidity documentation is the most comprehensive and up-to-date resource for learning about the Solidity language. It covers everything from basic syntax to advanced topics and provides detailed explanations, examples, and code snippets.
* **Link**: [Solidity Documentation](https://docs.soliditylang.org/en/latest/)
### Learning Resources
#### Online Tutorials and Courses
* **CryptoZombies**: An interactive online course that teaches Solidity through building a zombie game.
* **Link**: [CryptoZombies](https://cryptozombies.io/)
* **Dapp University**: A YouTube channel with over 10 hours of hands-on tutorials for both beginners and experienced Solidity developers.
* **Link**: [Dapp University](https://www.youtube.com/user/DappUniversity)
* **Udemy Ethereum Blockchain Developer Bootcamp With Solidity**: An extensive course providing up-to-date blockchain development tools and resources.
* **Link**: [Udemy Course](https://www.udemy.com/course/ethereum-and-solidity-the-complete-developers-guide/)
#### Community and Discussion
* **Ethereum StackExchange**: A platform for asking and answering questions related to Solidity and Ethereum development.
* **Link**: [Ethereum StackExchange](https://ethereum.stackexchange.com/)
* **Solidity Language Users Chat**: A chat room for Solidity developers to discuss and share knowledge.
* **Link**: [Solidity Chat](https://gitter.im/ethereum/solidity)
### Development Environments and Tools
#### Integrated Development Environments (IDEs)
* **Remix**: A browser-based IDE with an integrated compiler and Solidity runtime environment.
* **Link**: [Remix IDE](https://remix.ethereum.org/)
* **Hardhat**: An Ethereum development environment with local Ethereum network, debugging features, and a plugin ecosystem.
* **Link**: [Hardhat](https://hardhat.org/)
* **Foundry**: A fast, portable, and modular toolkit for Ethereum application development written in Rust.
* **Link**: [Foundry](https://github.com/foundry-rs/foundry)
#### Editor Integrations
* **Visual Studio Code (VS Code)**: Solidity extensions for syntax highlighting, compilation, and debugging.
* **Link**: [Solidity VS Code Extension](https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity)
* **IntelliJ IDEA**: Solidity plugin for IntelliJ IDEA and other JetBrains IDEs.
* **Link**: [IntelliJ IDEA Solidity Plugin](https://plugins.jetbrains.com/plugin/10479-solidity)
#### Linters and Tools
* **Solhint**: A Solidity linter that provides security, style guide, and best practice rules for smart contract validation.
* **Link**: [Solhint](https://github.com/protofire/solhint)
* **Ethlint**: A linter to identify and fix style and security issues in Solidity.
* **Link**: [Ethlint](https://github.com/duaraghav8/Ethlint)
### Additional Resources
#### Example Projects
* **Solidity by Example**: A collection of example contracts to help you understand Solidity in practice.
* **Link**: [Solidity by Example](https://docs.soliditylang.org/en/latest/solidity-by-example.html)
#### Security and Best Practices
* **Security Considerations**: A section in the Solidity documentation that provides guidance on security best practices.
* **Link**: [Security Considerations](https://docs.soliditylang.org/en/latest/security-considerations.html)
### Community Translations
The Solidity documentation is available in multiple languages, thanks to community volunteers.
* **Chinese (Simplified)**: [Solidity Documentation (Chinese)](https://readthedocs.org/projects/solidity-zh/downloads/pdf/latest/)
* **Spanish**: [Solidity Documentation (Spanish)](https://solidity.readthedocs.io/es/latest/)
* **Russian**: [Solidity Documentation (Russian)](https://solidity.readthedocs.io/ru/latest/)
### Third-Party Tools and Parsers
* **Solidity Parser for JavaScript**: A Solidity parser built on top of ANTLR4 grammar for JavaScript.
* **Link**: [Solidity Parser for JavaScript](https://github.com/federicobond/solidity-parser-antlr)
* **Sūrya**: A utility tool for smart contract systems, offering visual outputs and information about contract structure.
* **Link**: [Sūrya](https://github.com/ConsenSys/surya)프로젝트로 돌아가기