ZKsync 백서

ZKsync

원문

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

'Transaction sent successfully' ); const newCount = await publicClient. readContract ({ address: CONTRACT_ADDRESS , abi: counterContract.abi as Abi , functionName: 'x' , }); console. log ( 'New count:' , newCount); Run the script npm yarn pnpm bun npx hardhat run scripts/increment.ts Install the Hardhat verify SDK: npm yarn pnpm bun npm install --save-dev @nomicfoundation/hardhat-verify Add hardhatVerify to the hardhat plugins and configure the verification endpoint: hardhat.config.ts import hardhatVerify from "@nomicfoundation/hardhat-verify" ; const config : HardhatUserConfig = { plugins: [ hardhatVerify, // ...other plugins... ], // ...other config... chainDescriptors: { 8022833 : { name: 'zksyncOS' , blockExplorers: { blockscout: { name: 'Testnet Explorer' , url: 'https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev' , apiUrl: 'https://block-explorer-api.zksync-os-testnet-alpha.zksync.dev/api' , }, }, }, }, }; Use your deployed contract address to verify using hardhat-verify : npm yarn pnpm bun npx hardhat verify --network zksyncOS 0x < YOUR_CONTRACT_ADDRES S > Create a new project folder mkdir hardhat-example cd hardhat-example Initialize a new Hardhat 3 project with Mocha and Ethers.js. npx hardhat --init Add ZKsync OS to the hardhat.config.ts file and configure the ignition required confirmations. hardhat.config.ts ignition : { requiredConfirmations : 1 , }, networks : { zksyncOS : { type : 'http' , chainType : 'generic' , url : 'https://zksync-os-testnet-alpha.zksync.dev' , accounts : [ configVariable ( 'TESTNET_PRIVATE_KEY' )], }, }, Add your private key to the keystore as TESTNET_PRIVATE_KEY . npm yarn pnpm bun npx hardhat keystore set TESTNET_PRIVATE_KEY Compile and deploy the example contract. npm yarn pnpm bun npx hardhat compile npm yarn pnpm bun npx hardhat ignition deploy ignition/modules/Counter.ts --network zksyncOS Create a new script file in the scripts folder called increment.ts . touch scripts/increment.ts Copy/paste the script below. increment.ts import { network } from 'hardhat' ; const CONTRACT_ADDRESS = '0x8e882b31Fe1d3942c57408D354E754d1659400a7' ; const { ethers } = await network. connect ({ network: 'zksyncOS' , chainType: 'generic' , }); const [ sender ] = await ethers. getSigners (); const contract = await ethers. getContractAt ( 'Counter' , CONTRACT_ADDRESS , sender); const initialCount = await contract. x (); console. log ( 'Initial count:' , initialCount); const tx = await contract. inc (); await tx. wait (); console. log ( 'Transaction sent successfully' ); const newCount = await contract. x (); console. log ( 'New count:' , newCount); Run the script npm yarn pnpm bun npx hardhat run scripts/increment.ts Install the Hardhat verify SDK: npm yarn pnpm bun npm install --save-dev @nomicfoundation/hardhat-verify Add hardhatVerify to the hardhat plugins and configure the verification endpoint: hardhat.config.ts import hardhatVerify from "@nomicfoundation/hardhat-verify" ; const config : HardhatUserConfig = { plugins: [ hardhatVerify, // ...other plugins... ], // ...other config... chainDescriptors: { 8022833 : { name: 'zksyncOS' , blockExplorers: { blockscout: { name: 'Testnet Explorer' , url: 'https://zksync-os-testnet-alpha.staging-scan-v2.zksync.dev' , apiUrl: 'https://block-explorer-api.zksync-os-testnet-alpha.zksync.dev/api' , }, }, }, }, }; Use your deployed contract address to verify using hardhat-verify : npm yarn pnpm bun npx hardhat verify --network zksyncOS 0x < YOUR_CONTRACT_ADDRES S > Network Details Connect to ZKsync OS Developer Preview testnet FAQs Answers to frequently asked questions about ZKsync OS. ## /zksync-network/zksync-os/faqs ZKsync Docs FAQs Answers to frequently asked questions about ZKsync OS. What are the main benefits of ZKsync OS? The main benefits of ZKsync OS over the previous system include faster performance, higher TPS, the ability to support multiple execution environments, and the decoupling of the prover from execution to enable faster upgrades. What changes to development workflows will be required to use ZKsync OS? Developers will be able to use standard EVM tooling and compilers for contract deployment and interaction instead of ZKsync-specific tooling and compilers like zksolc and zkvyper . For app developers, are there any differences from the Ethereum EVM? ZKsync OS is fully EVM equivalent. Like with other EVM equivalent L2 solutions, there are a few distinctions that app developers should take note of: ZKsync OS will initially target Cancun for the first version. Support for Pectra will be added soon after. ZKsync OS provides some additional L2-specific functionality like sending messages to the L1. ZKsync OS can charge additional gas at the end of a transaction to cover pubdata and some additional costs. This doesn’t affect the behavior of contracts, but can require higher gas limits / gas price. See the Double Resource Accounting doc for more information. A different state model is used. For app developers this only affects storage proofs. More details about the storage model can be found in the zksync-os repository . Blake2f ( 0x09 ) and KZG point evaluation ( 0x0a ) precompiles are not yet supported. Is ZKsync OS replacing EraVM? Will existing chains upgrade to it? Yes, ZKsync OS will replace EraVM for ZKsync chains. Eventually chains that use EraVM with the legacy system will be deprecated. If there are multiple execution environments, why can’t ZKsync OS run EraVM? It is feasibly possible to run EraVM with ZKsync OS in the future. However, to enable chains to use ZKsync OS earlier, EVM was prioritized as the first and only execution environment for the initial version. What will it mean for projects that use native account abstraction on EraVM? ZKsync OS will use EVM. EraVM and native EraVM account abstraction are not supported. Any projects that currently rely on native account abstraction on EraVM that wish to switch to ZKsync OS must be migrated. ERC-4337 is supported with ZKsync OS. EIP-7702 is not yet supported, but will be soon. How can builders leverage any new features or capabilities? In the initial version of ZKsync OS, capabilities will be similar to those of other EVM L2 chains. However, in the future support for multiple execution environments will enable builders to use alternative programming languages to write smart contracts. Will chains that use ZKsync OS be able to use interop? Yes, chains that use ZKsync OS will also be able to use interop. Does ZKsync OS change what stage ZKsync chains are at? No, on its own chains that use ZKsync OS will not affect their stage level. However, it may make it easier to move to stages 1 and 2 because improvements to the prover can be deployed more efficiently. Is there a public testnet and mainnet? A public developer preview testnet is live and ready for testing. You can find the more information in this section of the docs for the network details and getting started with development. Currently there is no public mainnet. How can I run it locally? Because ZKsync OS is fully EVM-compatible, you can use any local EVM node such as anvil or hardhat-node to test a project locally. If your project requires some ZKsync-specific functionality (e.g. deposits/withdrawals/interop), you can follow the quickstart instructions in the zksync-os-server repository. How can I run it in a GitHub Action? You can use this action to run a setup with an L1 and ZKsync OS L2 chain. Are there pre-deployed contracts? Yes, all pre-deployed contracts that were available on EraVM with the exceptions of the Create2 Deployer and Safe contracts are available. Developer Quickstart Getting starting developing with ZKsync OS About ZKsync Era Understand the role of ZKsync Era within the ZKsync ecosystem, its architecture, and developer experience. ## /zksync-network/zksync-era ZKsync Docs About ZKsync Era Understand the role of ZKsync Era within the ZKsync ecosystem, its architecture, and developer experience. ZKsync Era is a Layer 2 rollup built with the ZK Stack , designed to scale Ethereum using zero-knowledge proofs while preserving its security. It was the first chain launched with the ZK Stack and the first member of the Elastic Network , which now includes over 15 interconnected ZK chains . Architecture ZKsync Era operates as a zero-knowledge rollup (ZK rollup) . It executes transactions off-chain, aggregates them into batches, and generates a succinct zero-knowledge validity proof to verify all state changes. This proof is then submitted to Ethereum, ensuring correctness and finality while reducing gas costs. Era uses the EraVM , a high-performance virtual machine that is compatible with the Ethereum Virtual Machine (EVM). Developers can deploy existing Solidity or Vyper contracts on Era with minimal or no changes. Core Components Sequencer — Orders and executes transactions off-chain to produce state updates. Prover — ZKsync Era uses the Boojum prover. It generates validity proofs for batches of transactions. Verifier — A smart contract on Ethereum that verifies proofs and finalizes state transitions. EraVM — Executes smart contracts bytecode with additional optimizations for ZK proof generation. Position in the Ecosystem ZKsync Era forms the foundation of the Elastic Network , a growing set of ZKsync chains that interoperate through shared proofs and trustless bridging. As the first ZKsync chain, it serves as the main hub for the ecosystem’s activity and infrastructure. Era is where the ZK token was initially deployed and where on-chain governance takes place, making it the coordination layer for protocol upgrades and community decision-making. Because of its early launch and adoption, ZKsync Era integrates with major exchanges, infrastructure providers such as Chainlink , and hosts deployments from many leading DeFi protocols . These integrations, assets, and tools will be accessible to other ZKsync chains through ZKsync Connect , ensuring that all chains in the Elastic Network benefit from access to the same liquidity, infrastructure, and ecosystem support while maintaining independent execution environments. Developer Experience ZKsync Era is designed to feel familiar to Ethereum developers. ZKsync Era uses EraVM as its core virtual machine. Contracts compiled for EraVM run directly on EraVM. Standard EVM bytecode is supported through the EVM Bytecode Interpreter, which executes that bytecode on top of EraVM. For the lower-level execution model and tradeoffs, see the EVM Bytecode Interpreter documentation . This lets teams use common Ethereum tools such as Hardhat, Foundry, and Remix. Teams that want the most efficient execution path can still compile contracts for EraVM directly using custom compilers and plugins. Although ZKsync Era continues to run on EraVM, all new ZKsync chains use ZKsync OS . User Experience For end users, transactions on ZKsync Era offer faster confirmations and significantly lower fees compared to Ethereum mainnet. Era also supports native account abstraction , enabling smart wallets, flexible fee payments using ERC-20 tokens, and features like paymasters for gas sponsorship. FAQs Answers to frequently asked questions about ZKsync OS. ZKsync Era RPC Step-by-step guide to connect your wallet to ZKsync Era mainnet and testnet. ## /zksync-network/zksync-era/network-details ZKsync Docs ZKsync Era RPC Step-by-step guide to connect your wallet to ZKsync Era mainnet and testnet. Add ZKsync Era to your MetaMask wallet You can add ZKsync Era to your MetaMask wallet using the buttons below: Add ZKsync Era Mainnet Add ZKsync Sepolia Testnet If you are using a different in-browser wallet, the buttons above may also work for them. Manually add ZKsync Era To manually add ZKsync Era as a custom network in your wallet, follow these steps: Find the “Add Network” option in your wallet (in MetaMask, you can find this in the networks dropdown). Click on “Add Network" and "Add network manually". Fill in the following details for the ZKsync Era network environments: Network details Property Value Network Name ZKsync Era Mainnet RPC URL https://mainnet.era.zksync.io WebSocket URL wss://mainnet.era.zksync.io/ws Chain ID 324 Currency Symbol ETH Block Explorer URL https://explorer.zksync.io Explorer Verification API https://zksync2-mainnet-explorer.zksync.io/contract_verification Property Value Network Name ZKsync Era Sepolia RPC URL https://sepolia.era.zksync.dev WebSocket URL wss://sepolia.era.zksync.dev/ws Chain ID 300 Currency Symbol ETH Block Explorer URL https://sepolia.explorer.zksync.io Explorer Verification API https://explorer.sepolia.era.zksync.dev/contract_verification Get testnet funds for your wallet Once you have your wallet connected to a ZKsync Era environment, you can get testnet funds from one of many testnet faucets to use with deploying your first smart contract . About ZKsync Era Understand the role of ZKsync Era within the ZKsync ecosystem, its architecture, and developer experience. 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 ## /zksync-network/zksync-era/unique-features ZKsync Docs 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 ZKsync Era and other ZKsync chains powered by EraVM introduce several protocol-level features that extend Ethereum’s capabilities while maintaining compatibility with existing tools and workflows. These include native Account Abstraction , Paymasters , and an EVM Bytecode Interpreter for seamless integration with the Ethereum ecosystem. The following features apply to ZKsync Era and other ZKsync chains powered by EraVM. Native Account Abstraction ZKsync Era and other ZKsync chains powered by EraVM natively support Account Abstraction (AA) , allowing accounts to include custom logic at the protocol level. This enables smart accounts that can define how transactions are authorized and executed, unlocking use cases such as: Account recovery and social recovery mechanisms Native multisignature accounts Session keys and programmable spending rules To learn more about Account Abstraction design, see the protocol documentation . If you prefer a practical approach, explore these tutorials: Native multisig smart account Daily spending limit account Paymasters ZKsync Era and other ZKsync chains powered by EraVM also include native support for Paymasters , an extension of the Account Abstraction model introduced in EIP-4337 . Paymasters act as an intermediate layer in transaction processing, controlling how fees are paid or sponsored. Common use cases include: Paying transaction fees in ERC-20 or NFT tokens Subsidizing transactions for onboarding or promotions Managing fee payments for a predefined set of accounts For details on Paymaster design, see the protocol documentation . Testnet Paymaster To simplify testing, ZKsync Sepolia Testnet provides a built-in testnet paymaster that supports ERC-20 fee payments. Key details Address : 0x3cb2b87d10ac01736a65688f3e0fb1b070b3eea3 ( View on explorer ) Chain : ZKsync Sepolia Testnet Exchange rate : 1:1 with ETH (1 token unit = 1 wei) Flow type : Approval-based Usage requirements : token : must match the ERC-20 token used for fee payment minimalAllowance : at least tx.maxFeePerGas * tx.gasLimit innerInput : must be empty ( 0x ) Example usage const paymasterParams = { paymaster: "0x3cb2b87d10ac01736a65688f3e0fb1b070b3eea3" , paymasterInput: { type: "ApprovalBased" , token: "<ERC20_TOKEN_ADDRESS>" , minimalAllowance: tx.maxFeePerGas * tx.gasLimit, innerInput: "0x" , }, }; This setup lets developers simulate ERC-20-based fee payments in a testnet environment without deploying a custom paymaster. Paymaster Tutorials Build an ERC20 custom paymaster Dapp with gated NFT paymaster Frontend Quickstart with a Paymaster Integrate permissionless multi-signer paymaster EVM Bytecode Interpreter The EVM Bytecode Interpreter on ZKsync Era and other ZKsync chains powered by EraVM provides runtime compatibility for Ethereum smart contracts. It translates EVM instructions into EraVM instructions during execution, allowing developers to deploy contracts compiled with standard Ethereum toolchains—without using ZKsync-specific compilers ( zksolc , zkvyper ). This enables development with Foundry , Hardhat , or Remix directly, without requiring custom Hardhat plugins or custom Foundry forks . Main Features EVM Bytecode Support — Run unmodified EVM bytecode without recompilation. Tooling Compatibility — Use standard Ethereum development tools out of the box. Address Derivation Consistency — create and create2 behave identically to the EVM. Predeployed Contracts — Includes create2 , multicall3 , and singletonFactory (ERC-2470). See the protocol documentation for a complete list. Limitations Debugging — EVM-compatible debugging tools are not yet supported due to EraVM-specific internals. Gas Model — EVM gas rules are emulated; actual costs follow the EraVM model. See EVM gas interpretation . Unsupported Opcodes — The same opcodes as in EraVM remain unsupported: CALLCODE , SELFDESTRUCT , BLOBHASH , BLOBBASEFEE . Transaction Costs — Bytecode translation introduces overhead, typically increasing costs by 1.5×–4× depending on execution complexity. Learn more about differences from Ethereum (Cancun) . Considerations for Developers The EVM interpreter allows developers to use familiar workflows without custom compilers or plugins. However, the translated execution model incurs higher gas costs. For production deployments, compiling contracts to native EraVM bytecode using zksolc or zkvyper is recommended for optimal performance and efficiency. ZKsync Era RPC Step-by-step guide to connect your wallet to ZKsync Era mainnet and testnet. 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. ## /zksync-network/zksync-era/custom-tooling ZKsync Docs 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. Before the EVM Bytecode Interpreter made standard Ethereum toolchains work directly on ZKsync Era and other ZKsync chains powered by EraVM, several tools were built specifically for native EraVM workflows. This page keeps a high-level reference to those tools so older documentation, repositories, and search results remain understandable. For most new development on ZKsync Era and other ZKsync chains powered by EraVM, standard Ethereum tooling can now be used directly through the EVM Bytecode Interpreter . New ZKsync chains powered by ZKsync OS are not compatible with any of the tools below. EraVM-specific tools hardhat-zksync The official Hardhat plugin suite for ZKsync Era and EraVM-powered ZKsync chains. It was used to compile, deploy, verify, and upgrade contracts targeting native EraVM bytecode from Hardhat projects. The main entrypoint was @matterlabs/hardhat-zksync , which bundled the plugin suite for compilation, deployment, testing, and verification. The tooling included @matterlabs/hardhat-zksync together with plugins such as @matterlabs/hardhat-zksync-solc , @matterlabs/hardhat-zksync-vyper , @matterlabs/hardhat-zksync-deploy , @matterlabs/hardhat-zksync-verify , @matterlabs/hardhat-zksync-verify-vyper , @matterlabs/hardhat-zksync-upgradable , @matterlabs/hard
프로젝트로 돌아가기