ZKsync 백서

ZKsync

원문

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

hat-zksync-ethers , and @matterlabs/hardhat-zksync-node . Because the suite extended standard Hardhat behavior, it could also replace or conflict with common plugins such as @nomicfoundation/hardhat-ethers . Multichain projects could require additional care when combining it with OpenZeppelin upgrades tooling. Repository: hardhat-zksync . foundry-zksync A specialized fork of Foundry for ZKsync Era and EraVM-powered ZKsync chains. It extended forge and cast with ZKsync-aware compilation, deployment, and testing workflows, including support for zksolc , --zksync execution, and other EraVM-specific behavior. The toolchain was typically installed with foundryup-zksync . It also shipped anvil-zksync for local development and debugging. Typical workflows used commands such as forge build --zksync , forge test --zksync , and forge create --zksync . Repository: foundry-zksync . Documentation: Foundry ZKsync Book . anvil-zksync The in-memory local node used for fast development on ZKsync Era and EraVM-powered ZKsync chains. It supported quick local startup, pre-funded test accounts, network forking, verbose execution traces, and replaying remote transactions locally for debugging. It was the lightweight option for local testing. For workflows that needed deeper Layer 1 and Layer 2 interaction, the Dockerized local setup was the more complete environment. The anvil-zksync GitHub Action was used to integrate anvil-zksync into CI/CD workflows for ZKsync Era and EraVM-powered ZKsync chains. It was mainly used in GitHub Actions pipelines to start a local node in run or fork mode, then execute contract and integration tests against that environment. The action exposed configuration for the network, fork height, port, debug output, target architecture, and log file handling. It was a lightweight way to automate local EraVM testing in pull requests and other CI jobs. Repository: anvil-zksync . Marketplace: anvil-zksync-action . Dockerized local setup The Dockerized local setup provided a fuller local environment for ZKsync Era and EraVM-powered ZKsync chains than anvil-zksync . It ran a Postgres database, a local Layer 1 node, and a ZKsync node together so you could test end-to-end Layer 1 to Layer 2 flows. This setup was mainly used for integration scenarios that needed both chains present locally. It was slower to start and heavier to operate than anvil-zksync , but it exposed a broader set of node behavior. Repository: local-setup . Pre-configured rich wallets anvil-zksync and the Dockerized local setup used the same public, pre-funded development wallets for local testing. Use these accounts only in local environments. Never use their private keys or mnemonics on mainnet or with real funds. Rich wallets Same mnemonic rich wallets ZKsync External Node The ZKsync External Node was a read-only replica of the main node for ZKsync Era and other EraVM-powered ZKsync chains. It synchronized chain data from the main node, re-executed transactions locally, and exposed a Web3 API for querying chain state without relying directly on the primary public endpoint. It was mainly used for archive-style access, local state verification, and running dedicated RPC infrastructure for applications and operators. It could proxy Layer 2 transactions to the main node, but it could not produce blocks, generate proofs, or act as a consensus node. Documentation: ZKsync External Node guide zksync-ethers zksync-ethers was the JavaScript SDK for ZKsync Era and other EraVM-powered ZKsync chains. It was designed to stay close to the ethers interface while adding support for ZKsync-specific transaction fields and workflows. It was commonly used for contract deployment, native account abstraction, paymaster integrations, and Layer 1 to Layer 2 bridging. Repository: zksync-ethers Other SDKs Additional SDKs were also maintained for ZKsync Era and other EraVM-powered ZKsync chains in Java, Go, Python, and Swift. They provided helpers for contract deployment, native account abstraction, paymaster integrations, and bridging workflows. Java: zksync2-java Go: zksync2-go Python: zksync2-python Swift: zksync2-swift zksync-cli The all-in-one command-line tool for many workflows on ZKsync Era and EraVM-powered ZKsync chains. It could scaffold projects, start local development environments, inspect transactions, manage wallets, bridge assets, interact with contracts, and configure custom chains. Older guides may reference commands such as zksync-cli create , zksync-cli dev , zksync-cli wallet , zksync-cli bridge , zksync-cli contract , zksync-cli transaction , and zksync-cli config chains . It was also used to bootstrap Hardhat-based starter projects and Docker-backed local environments. Repository: zksync-cli . ZKsync Easy On-Ramp ZKsync Easy On-Ramp was a hosted service for buying ETH and ERC-20 tokens on ZKsync Era with fiat payment methods such as cards, Apple Pay, Google Pay, and bank transfer. It was mainly used as a lightweight purchase flow through the ZKsync Portal, without requiring a custom SDK integration or a separate bridge step. Features Learn about the features available on ZKsync Era and other ZKsync chains powered by EraVM, including native Account Abstraction, Paymasters, and the EVM Bytecode Interpreter Ecosystem Curated ecosystem links for ZKsync Era. ## /zksync-network/zksync-era/ecosystem ZKsync Docs Ecosystem Curated ecosystem links for ZKsync Era. This page lists third-party tools and services that you can use with ZKsync Era. The list is intentionally selective. Always verify current support and functionality before relying on any external service. Bridges Portal Bridge : Official bridge for moving assets between Ethereum and ZKsync Era. Across Bridge : Cross-chain bridge that supports transfers involving ZKsync Era. Layerswap : Asset transfer service that supports deposits to ZKsync Era. Orbiter Finance : Bridge page with ZKsync Era selected as the destination network. Owlto Finance : Bridge service used for transfers to and from ZKsync Era. Block explorers Official explorer The official ZKsync Era Block Explorer is the main interface for inspecting transactions, blocks, batches, wallets, tokens, and smart contracts on the network. It also provides the standard explorer API and contract verification endpoints used in many ZKsync Era workflows. Mainnet: ZKsync Era Block Explorer Testnet: ZKsync Era Testnet Block Explorer Mainnet API Swagger: block-explorer-api.mainnet.zksync.io/docs Testnet API Swagger: block-explorer-api.sepolia.zksync.dev/docs Mainnet verification API: https://zksync2-mainnet-explorer.zksync.io/contract_verification Testnet verification API: https://explorer.sepolia.era.zksync.dev/contract_verification Repository: block-explorer Other explorers Blockscout Mainnet Blockscout Testnet OKLink Cross-chain messaging Chainlink CCIP : Cross-chain messaging and token transfer protocol used with ZKsync-related workflows. LayerZero : Omnichain messaging protocol used by applications that integrate ZKsync Era. Faucets Alchemy Chainstack GetBlock LearnWeb3 Circle Testnet Faucet Indexing and analytics DipDup : Indexing framework used for ZKsync-oriented data services. Dune : Analytics platform with ZKsync dashboards and queries. Envio : Indexing and data infrastructure used by ZKsync applications. GoldRush : ZKsync Era data API page. Space and Time : Data platform used alongside ZKsync ecosystem applications. SubQuery : Indexing stack that supports ZKsync integrations. Subsquid : Indexing toolkit used for ZKsync data pipelines. The Graph : Indexing protocol used by applications that expose data from ZKsync Era. NFT marketplaces Element : NFT marketplace that supports ZKsync Era collections. Oracles Chainlink : Price feed addresses page for the ZKsync network. Chronicle : Oracle documentation used in ZKsync-related integrations. DIA : Token price feed documentation used in ZKsync integrations. Pyth : Price feed documentation used by ZKsync ecosystem applications. RPC providers Alchemy : ZKsync RPC and API page. Ankr : ZKsync RPC page. Blockdaemon : ZKsync RPC service page. BoltRPC : ZKsync Era RPC endpoints page. Chainstack : Infrastructure provider used with ZKsync deployments. dRPC : ZKsync RPC endpoints page. GetBlock : ZKsync node and RPC page. NOWNodes : Node provider that offers ZKsync access. QuickNode : ZKsync RPC and data page. Unifra : Web3 infrastructure provider used with ZKsync. Paymasters ZyFi : Paymaster and gas abstraction service used in the ZKsync ecosystem. Wallets Enkrypt : Dedicated ZKsync wallet page. Holdstation : Wallet and trading app with ZKsync Era support. MetaMask : Widely used wallet that can connect to ZKsync Era. OKX Wallet : Wallet and Web3 app suite that supports ZKsync Era usage. Openfort : Wallet infrastructure provider used in the ZKsync ecosystem. Rabby Wallet : Multi-chain wallet commonly used with ZKsync Era applications. Reown : Wallet connection and onboarding tooling used by applications that support ZKsync Era. Zerion : Wallet and portfolio app that supports ZKsync Era. Custom Tooling Reference page for legacy tooling used on ZKsync Era and other ZKsync chains powered by EraVM that older guides and search results may still mention. Security and best practices Guidelines to help you build secure, efficient, and maintainable smart contracts on ZKsync chains powered by EraVM. ## /zksync-network/zksync-era/security-best-practices ZKsync Docs Security and best practices Guidelines to help you build secure, efficient, and maintainable smart contracts on ZKsync chains powered by EraVM. Before developing on a ZKsync chain running EraVM, review these best practices. Following these recommendations will help you optimize performance, maintain security, and align your contracts with the design of the EraVM. Use call instead of .send or .transfer Avoid using payable(addr).send(x) or payable(addr).transfer(x) . These functions only provide a 2300 gas stipend, which may not be enough if the call triggers state changes or other operations that require more L2 gas. Use call instead. Instead of: payable (addr). send (x); // or payable (addr). transfer (x); Use: ( bool s, ) = addr.call{value : x}( "" ); require (s); This approach replicates the behavior of .send or .transfer while providing more flexibility and avoiding gas-limit issues. See Consensys’ explanation of .transfer risks for additional context. While .call is safer in terms of gas, it does not provide built-in reentrancy protection. To prevent vulnerabilities: Follow the checks-effects-interactions pattern. Use a reentrancy guard when interacting with external contracts. These practices help secure your contracts against reentrancy attacks and unexpected external behavior. Use the Proxy Pattern ZKsync chains running EraVM support Solidity and Vyper code compilation into EraVM bytecode using custom compilers. Although the compilers undergoes extensive testing to ensure EVM compatibility, minor issues can occasionally appear. ZKsync chains running EraVM also support EVM Bytecode from the solc compiler. To handle potential compiler patches or updates, use the Proxy pattern when deploying new contracts. This allows you to recompile and upgrade your contract logic without requiring a full redeployment. After your contracts have proven stable, you can migrate to an immutable version if desired. Using the Proxy pattern during the initial deployment phase reduces maintenance effort and ensures flexibility as the EraVM continues to evolve. Do Not Rely on Ethereum Gas Logic The gas model on ZKsync chains running EraVM differs from Ethereum’s. Two key factors influence gas costs: State-diff-based data availability – transaction costs depend on L1 gas prices. Distinct computational model – the EraVM uses a different opcode pricing model and computational trade-offs compared to the EVM. Because of these differences, gas usage on a ZKsync chain cannot be directly compared to Ethereum. Avoid hardcoding gas constants in your contracts, as future changes to ZKsync’s fee model could make these assumptions invalid. Account for gasPerPubdataByte Each transaction on ZKsync includes a constant called gasPerPubdataByte . This value is set by the operator, although users define an upper bound for it in EIP-712 transactions. Since gasPerPubdataByte fluctuates with L1 gas prices, relying solely on gas limits can lead to unpredictable behavior. For example, in Gnosis Safe’s execTransaction method: // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500) // We also include the 1/64 in the check that is not send along with a call to counteract potential shortcomings because of EIP-150 require ( gasleft () >= ((safeTxGas * 64 ) / 63 ). max (safeTxGas + 2500 ) + 500 , "GS010" ); // Use scope here to limit variable lifetime and prevent `stack too deep` errors { uint256 gasUsed = gasleft (); // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas) // We only subtract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas success = execute (to, value, data, operation, gasPrice == 0 ? ( gasleft () - 2500 ) : safeTxGas); gasUsed = gasUsed. sub ( gasleft ()); // ... } This logic enforces a minimum gasleft() but does not account for gasPerPubdata . A malicious user could exploit a high gasPerPubdata value to increase gas costs or cause transaction failures. When porting logic from Ethereum: Include gasPerPubdata in your gas calculations. Add a safety margin to handle price fluctuations. Avoid assumptions based on Ethereum’s static gas model. Currently, ZKsync operators use accurate and fair values for ETH L1 pricing and gasPerPubdata , but preparing your contracts for future decentralization ensures long-term stability and reliability. Use Native Account Abstraction for Validation Do not rely on ecrecover for signature verification. ZKsync chains running EraVM use native account abstraction , which supports flexible authentication mechanisms such as multisignature wallets or custom signature schemes. Assuming all accounts use ECDSA private keys may cause compatibility issues. Instead, rely on the built-in account abstraction mechanisms for validation to ensure forward compatibility. Learn more in the Account Abstraction guide . Test in a Local Environment Always test your contracts locally before deploying to mainnet. Local testing allows you to verify contract behavior in a controlled environment, reduce latency, and avoid transaction costs. anvil-zksync allows you to simulate mainnet behavior for development purposes. To test locally: Set up the local environment using one of the available tools. Run your tests with frameworks such as Foundry and Hardhat to verify expected behavior. Review results and confirm that events, gas usage, and outputs match expectations. Iterate and refine before deploying to testnet or mainnet. Local testing helps you identify issues early, ensuring a more reliable and predictable deployment on ZKsync chains. By following these best practices, you can improve the security, reliability, and maintainability of your smart contracts across all ZKsync chains powered by the EraVM. Ecosystem Curated ecosystem links for ZKsync Era. Contributing to Documentation Learn how to propose, write, and validate documentation changes for ZKsync Docs. ## /zksync-network/contributing ZKsync Docs Contributing to Documentation Learn how to propose, write, and validate documentation changes for ZKsync Docs. Use this page if you want to improve ZKsync Docs. It covers small edits in the browser, larger changes in a local checkout, documentation-specific writing rules, and the checks to run before you open a pull request. Choose how to contribute You can contribute in two ways: For quick fixes, use the Edit this page link on a docs page and submit a small change in GitHub. For larger edits, fork the zksync-docs repository , create a branch from main , and open a pull request. If you want to report a problem without preparing a patch, use the Share feedback link in the docs sidebar or open an issue in GitHub . If your pull request is not ready for review yet, open it as a draft pull request . Set up the docs locally Follow the root README.md to install dependencies and run the site locally. The basic workflow is: bun install bun run dev The local development server runs at http://localhost:3000 . For the best editing experience, use VS Code and install the recommended workspace extensions from .vscode/extensions.json . Understand the docs structure Most documentation changes happen in the /content directory. File and directory names use a two-digit numeric prefix to control navigation order. When you create a new directory, create 00.index.md as the landing page for that route. Use _dir.yml to set the navigation title for a section. Every page must include frontmatter with title and description . Internal links are generated from the /content path. Do not include the numeric prefix or file extension in the URL. Example: [ Quick Start ]( /zksync-network/quick-start ) Write for documentation Keep documentation direct, clear, and easy to scan. Write in active voice. Prefer inclusive and global language. Keep content focused on the reader's task. Use the Diataxis model to decide whether a page is a tutorial, guide, reference, or explanation. When you add or update a page: Use concise headings and keep one topic per section. Add code fences with language identifiers. Keep examples short and realistic. Add images under public/images/ and reference them from /images/... . Always include descriptive alt text for images. If spellcheck flags a valid project term, add it to the appropriate list in /cspell-config . Use the docs toolchain ZKsync Docs is built with Nuxt , Nuxt Content , Nuxt UI , and Tailwind . Use standard markdown for most changes. When you need richer layouts, use the markdown component syntax supported by Nuxt Content. Components are available in markdown pages. Example inline component syntax: :u-icon{name="i-heroicons-light-bulb"} If you are adding tabs, callouts, or similar structured content, check existing pages first and follow the same patterns. Validate your changes Before you open a pull request, run the checks that match your change. For docs content changes, run: bun run lint:spelling bun run lint:markdown bun run lint:prettier If your change also touches code or configuration, run the full check suite: bun run ci:check Open the pull request Create your branch from main and use Conventional Commits . For documentation changes, docs: is usually the right prefix. git commit -m "docs: update contributing to documentation page" Important : Git commits for this project should be signed with a verified signature . If you have not configured this yet, follow GitHub's guides to generate a signing key , add the key to your account , and tell Git about the key . Need help? If you are unsure how to structure or word a docs change, open an issue in GitHub . Security and best practices Guidelines to help you build secure, efficient, and maintainable smart contracts on ZKsync chains powered by EraVM. Protocol Contributions ## /zksync-network/contributing/protocol-contributions ZKsync Docs Protocol Contributions ZKsync is an open-source project. We champion community-driven development, which means you, from any corner of the world, can contribute to shaping ZKsync's future. Open-source repositories Here's a list of our key open-source repositories that you can contribute to: ZKsync OS ZKsync OS : Generalized RISC-V based state transition function for the ZKsync protocol. ZKsync OS
프로젝트로 돌아가기