Zircuit 백서

Zircuit

원문

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

-------------------- | | AccountingReceiver | [0x43c4a95788997a3E02F6Ca7E5CC4c23dbDE66c9C](https://basescan.org/address/0x43c4a95788997a3E02F6Ca7E5CC4c23dbDE66c9C) | | StrategyManager | [0x075193D36693DA7BA3Bb709cF63bEf070BA04D94](https://basescan.org/address/0x075193D36693DA7BA3Bb709cF63bEf070BA04D94) | | UnderlyingOFT | [0x264D6474802Ef8bc1bc05F89F7d640D1E93c5330](https://basescan.org/address/0x264D6474802Ef8bc1bc05F89F7d640D1E93c5330) | | VaultComposer | [0x16cE6D9576A411911e62b6073F1cc9d1347ad96B](https://basescan.org/address/0x16cE6D9576A411911e62b6073F1cc9d1347ad96B) | | Vault | [0x25d90ABd6c1E8DCCD40932D2fdD2Cd381bfc832D](https://basescan.org/address/0x25d90ABd6c1E8DCCD40932D2fdD2Cd381bfc832D) | *** ## **Ethereum** **USDC** | Contract | Address | | -------------------- | --------------------------------------------------------------------------------------------------------------------- | | StrategyManager | [0xf7E745658fa6f1fe8f2CAb47861a273991Cd3374](https://etherscan.io/address/0xf7E745658fa6f1fe8f2CAb47861a273991Cd3374) | | UnderlyingOFTAdapter | [0xd58E8c1c83d598aD76B5f0E26B4a25cdB885d190](https://etherscan.io/address/0xd58E8c1c83d598aD76B5f0E26B4a25cdB885d190) | | VaultToken | [0x07C898e77310870770f88d18a01009cB65A1c1a9](https://etherscan.io/address/0x07C898e77310870770f88d18a01009cB65A1c1a9) | **USDT** | Contract | Address | | -------------------- | --------------------------------------------------------------------------------------------------------------------- | | StrategyManager | [0x075193D36693DA7BA3Bb709cF63bEf070BA04D94](https://etherscan.io/address/0x075193D36693DA7BA3Bb709cF63bEf070BA04D94) | | UnderlyingOFTAdapter | [0x2D342De4c58a871b3525740C58a1C112D5835865](https://etherscan.io/address/0x2D342De4c58a871b3525740C58a1C112D5835865) | | VaultToken | [0x8ADbeA709B31A564f9750A280EC2690aD1cf470A](https://etherscan.io/address/0x8ADbeA709B31A564f9750A280EC2690aD1cf470A) | ## **Institutional Contracts** | Description | Address | Network | | ------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------- | | Monarq USDC Lender | [0xe83EF4375d806c02387069f1b753b2ab76ab1dc5](https://basescan.org/address/0xe83EF4375d806c02387069f1b753b2ab76ab1dc5) | Base | | Monarq USDT Lender | [0x1A48Cec817Bcb5436EFE99BAb6dDe228Cc37e1Cc](https://basescan.org/address/0x1A48Cec817Bcb5436EFE99BAb6dDe228Cc37e1Cc) | Base | | WisdomTree USDC Lender | [0x7C19aADD063487676b9Dc58968Ed0761d99cE80B](https://basescan.org/address/0x7C19aADD063487676b9Dc58968Ed0761d99cE80B) | Base | | Fidelity FDIT ERC20-Token | [0x48aB4e39AC59F4E88974804B04A991b3a402717f](https://etherscan.io/address/0x48aB4e39AC59F4E88974804B04A991b3a402717f) | Ethereum | # Security **Audit Reports** {% file src="/files/8WbnyPY4KEeLGmmMF30y" %} {% file src="/files/wLPZj6mL3u0oX9QM810E" %} {% file src="/files/Srhgb7ihJVb0k3xmfbhH" %} {% file src="/files/TSFoK3hLVjqdXNMcRGPo" %} {% file src="/files/KCpiPAdrIK8441NH5cNK" %} {% file src="/files/QYqI5VG3kmiEsAV1CiDQ" %} # Quick Start {% hint style="info" icon="triangle-exclamation" %} ## Note that [SLS](https://docs.zircuit.com/info/architecture/sls) is not enabled while we [focus](https://www.zircuit.com/blog/a-new-chapter-for-zircuit-from-l2-to-defi) on Zircuit Finance. Zircuit Finance does not rely on the Zircuit chain. {% endhint %} ## Connecting to Zircuit There are only a few simple steps to get started with Zircuit: 1. Install a Browser Wallet 2. Add Zircuit Network to Your Wallet 3. Get Ether (ETH) 4. Deposit ETH from Ethereum to Zircuit (L1 -> L2) **Install a Browser Wallet** First, you'll need to Ethereum wallet such as [MetaMask](https://metamask.io/) or [Rabby](https://rabby.io/). Add the corresponding extension to your browser. ## Add Zircuit to Your Wallet To start using Zircuit, you need to add the chain's RPC endpoint to your wallet. Navigate to the corresponding Chainlist page and add the Zircuit Network directly. <figure><img src="https://3252263143-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fp2pPzGBdConDaqw5tnHs%2Fuploads%2Fgit-blob-47feaaabae69ce548895375056a4b013ac0f0b5e%2FScreenshot%202025-10-02%20at%2018.19.53.png?alt=media" alt=""><figcaption></figcaption></figure> | | Zircuit Mainnet | Garfield Testnet | | --------------- | ----------------------------------- | ------------------------------------------------ | | RPCs | <https://chainlist.org/chain/48900> | <https://chainlist.org/chain/48898> | | Chain ID | 48900 | 48898 | | Currency Symbol | ETH | ETH | | Block Explorer | <https://explorer.zircuit.com> | <https://explorer.garfield-testnet.zircuit.com/> | # Bridge to Zircuit {% hint style="info" icon="triangle-exclamation" %} ## Zircuit Finance does not rely on the Zircuit chain. {% endhint %} ## Mainnet Zircuit uses ETH for gas. If you don't already have some in your wallet, you'll need to acquire some {% embed url="<https://ethereum.org/en/get-eth/>" %} ### Deposit ETH from Ethereum to Zircuit (L1 -> L2) You can bridge your ETH to Zircuit via the Zircuit Bridge. To do so, simply: 1. Connect your wallet on <https://bridge.zircuit.com/> 2. Make sure you're connected to Ethereum 3. Enter how much ETH you would like to bridge to Zircuit 4. Click `Bridge` 5. Review the transaction and click `Approve transaction in your wallet` 6. Click `Confirm` in the MetaMask popup 7. After a few seconds, your transaction should be confirmed, and you should see the updated balance ## Garfield Testnet If you are deploying on Zircuit Garfield Testnet, you can get Testnet ETH from the faucet located [here](https://ethglobal.com/faucet/zircuit-garfield-testnet-48898). {% hint style="info" %} If you get Garfield Testnet ETH this way, you do not need to bridge. {% endhint %} If you have [Sepolia ETH](https://chainstack.com/sepolia-faucet/) and would like to bridge: ### Deposit ETH from Sepolia to Garfield Testnet (L1 -> L2) You can bridge your Sepolia ETH to Garfield Testnet via the Zircuit Bridge. To do so, simply: 1. Connect your wallet on <https://bridge.garfield-testnet.zircuit.com/> 2. Make sure you're connected to Sepolia 3. Enter how much Sepolia ETH you would like to bridge to Zircuit 4. Click `Bridge` 5. Review the transaction and click `Approve transaction in your wallet` 6. Click `Confirm` in the popup 7. After a few seconds, your transaction should be confirmed, and you should see the updated balance # Deploy on Zircuit A tutorial for deploying a smart contract on Zircuit using Foundry {% hint style="info" icon="triangle-exclamation" %} ## Zircuit Finance does not rely on the Zircuit chain. {% endhint %} This tutorial will guide you through the complete process of setting up Foundry, creating a smart contract, and deploying it to the Zircuit testnet. Foundry is a powerful, fast, and portable toolkit for Ethereum application development written in Rust. ### Prerequisites Before starting, ensure you have: * A Unix-like operating system (macOS, Linux, or WSL on Windows) * Git installed * A wallet with some ETH on Zircuit * Basic understanding of Solidity and blockchain concepts ### What is Foundry? Foundry is a blazing fast, portable and modular toolkit for Ethereum application development. It consists of: * **Forge**: Ethereum testing framework (like Truffle, Hardhat) * **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data * **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network * **Chisel**: Fast, utilitarian, and verbose Solidity REPL {% stepper %} {% step %} **Set Up Foundry** First, we'll install Foundry using the official installer script: ```bash # Download and install Foundry curl -L https://foundry.paradigm.xyz | bash # Reload your shell configuration to make foundryup available source ~/.zshrc # for zsh users # OR source ~/.bashrc # for bash users # Install the latest version of Foundry tools foundryup ``` **What this does:** * Downloads the Foundry installer script * Installs `foundryup`, the Foundry toolchain installer * Updates your shell to recognize the new commands * Installs or updates `forge`, `cast`, `anvil`, and `chisel` **Verify installation:** ```bash forge --version ``` {% endstep %} {% step %} **Create a New Counter Project** Initialize a new Foundry project with the counter template: ```bash # Create a new Foundry project called 'counter' forge init counter # Navigate into the project directory cd counter ``` **What this creates:** ``` counter/ ├── lib/ # Dependencies (like node_modules) ├── script/ # Deployment scripts │ └── Counter.s.sol # Deployment script ├── src/ # Smart contract source files │ └── Counter.sol # Main contract ├── test/ # Test files │ └── Counter.t.sol # Contract tests └── foundry.toml # Foundry configuration file ``` {% endstep %} {% step %} **Set Up Your Private Key for Deployment** {% hint style="warning" %} Never use your mainnet private key for testing. Always use a separate wallet for testnet development. {% endhint %} You need to securely store your private key for contract deployment: {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast wallet import mainnetKey --interactive ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast wallet import testnetKey --interactive ``` {% endtab %} {% endtabs %} **What this does:** * Prompts you to enter your private key securely (won't display on screen) * Encrypts and stores the key locally under the name "defaultKey" * Requires a password to encrypt the stored key {% endstep %} {% step %} **Compile Your Smart Contract** Compile all contracts in your project: ```bash forge compile ``` **What this does:** * Compiles all `.sol` files in the `src/` directory * Generates ABI (Application Binary Interface) files * Creates bytecode for deployment * Checks for compilation errors and warnings * Outputs artifacts to `out/` directory **Expected output:** ``` [⠊] Compiling... [⠃] Compiling 23 files with Solc 0.8.30 [⠊] Solc 0.8.30 finished in 889.13ms Compiler run successful! ``` {% endstep %} {% step %} **Review the Contract and Deployment Script** Let's examine the smart contract and deployment script in detail: **src/Counter.sol** ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; contract Counter { // State variable to store the counter value uint256 public number; // Function to set the counter to a specific value function setNumber(uint256 newNumber) public { number = newNumber; } // Function to increment the counter by 1 function increment() public { number++; } } ``` **Contract explanation:** * `uint256 public number`: A public state variable that automatically generates a getter function * `setNumber()`: Allows setting the counter to any value * `increment()`: Increases the counter by 1 * All functions are `public`, meaning anyone can call them {% code title="script/Counter.s.sol" %} ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; import {Script} from "forge-std/Script.sol"; import {Counter} from "../src/Counter.sol"; contract CounterScript is Script { Counter public counter; function setUp() public {} function run() public { // Start recording transactions for broadcast vm.startBroadcast(); // Deploy the Counter contract counter = new Counter(); // Stop recording transactions vm.stopBroadcast(); } } ``` {% endcode %} **Deployment script explanation:** * Inherits from `Script` to access deployment utilities * `vm.startBroadcast()`: Begins recording transactions to broadcast to the network * `new Counter()`: Deploys a new instance of the Counter contract * `vm.stopBroadcast()`: Stops recording transactions {% endstep %} {% step %} **Deploy Your Smart Contract** Customize your `foundry.toml` for different networks: ```toml [profile.default] src = "src" out = "out" libs = ["lib"] # Zircuit RPC configuration [rpc_endpoints] zircuit_mainnet = "https://mainnet.zircuit.com" garfield_testnet = "https://garfield-testnet.zircuit.com" ``` Deploy the contract to Zircuit {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash forge script script/Counter.s.sol:CounterScript \ --rpc-url zircuit_mainnet \ --account mainnetKey \ --broadcast ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash forge script script/Counter.s.sol:CounterScript \ --rpc-url garfield_testnet \ --account testnetKey \ --broadcast ``` {% endtab %} {% endtabs %} **Command breakdown:** * `forge script`: Command to run deployment scripts * `script/Counter.s.sol:CounterScript`: Path to script file and contract name * `--rpc-url`: The RPC endpoint * `--account <key>`: Uses the imported private key * `--broadcast`: Actually sends transactions to the network **Expected output (Garfield Testnet):** ``` [⠊] Compiling... No files changed, compilation skipped Enter keystore password: Script ran successfully. ## Setting up 1 EVM. ========================== Chain 48898 Estimated gas price: 0.000000509 gwei Estimated total gas used for script: 203856 Estimated amount required: 0.000000000103762704 ETH ========================== ##### 48898 ✅ [Success] Hash: 0x59bf94e4055ee2c4a71b9e6a7b7589ad3a5831ac38717c5f0d488eb4ed365a77 Contract Address: 0x6E69d4f9bc6a3E2f67d2D86877800482A8cdca40 Block: 8549829 Paid: 0.000000000039987315 ETH (156813 gas * 0.000000255 gwei) ✅ Sequence #1 on 48898 | Total Paid: 0.000000000039987315 ETH (156813 gas * avg 0.000000255 gwei) ``` **Copy the Contract Address** from the output - you'll need it for the next step! {% endstep %} {% step %} **Interact with Your Smart Contract** Now that your contract is deployed, you can interact with it using `cast`. **Execute a State-Changing Function** To call the `increment()` function (which costs gas): {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast send <CONTRACT_ADDRESS> "increment()" \ --rpc-url https://mainnet.zircuit.com \ --account mainnetKey ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast send <CONTRACT_ADDRESS> "increment()" \ --rpc-url https://garfield-testnet.zircuit.com \ --account testnetKey ``` {% endtab %} {% endtabs %} **Replace `<CONTRACT_ADDRESS>` with your actual contract address from step 6.** **What this does:** * Sends a transaction to call the `increment()` function * Uses your imported private key to sign the transaction * Pays gas fees for the transaction **Expected output (Garfield Testnet):** ``` blockHash 0x97162a12dc900daf598e18c7a026d0b7bea5b121fc20bd99600292b53ba8148b blockNumber 8550305 contractAddress cumulativeGasUsed 91965 effectiveGasPrice 255 from 0xbd9B49deFc88AC16D7fC0F7FE6Eb7E0F54F6317f gasUsed 43482 ... ``` **Read Contract State** To read the current value of `number` (free, no gas required): {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast call <CONTRACT_ADDRESS> "number()" \ --rpc-url https://mainnet.zircuit.com ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast call <CONTRACT_ADDRESS> "number()" \ --rpc-url https://garfield-testnet.zircuit.com ``` {% endtab %} {% endtabs %} **Expected output:** ``` 0x0000000000000000000000000000000000000000000000000000000000000001 ``` This hexadecimal output represents the number `1`, showing that our increment worked! **To convert hex to decimal:** ```bash cast --to-dec 0x0000000000000000000000000000000000000000000000000000000000000001 # Output: 1 ``` **Additional Interaction Examples** Set the counter to a specific value: {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast send <CONTRACT_ADDRESS> "setNumber(uint256)" 42 \ --rpc-url https://mainnet.zircuit.com \ --account mainnetKey ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast send <CONTRACT_ADDRESS> "setNumber(uint256)" 42 \ --rpc-url https://garfield-testnet.zircuit.com \ --account testnetKey ``` {% endtab %} {% endtabs %} Check the balance of your deployer address: {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast balance <YOUR_WALLET_ADDRESS> \ --rpc-url https://mainnet.zircuit.com ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast balance <YOUR_WALLET_ADDRESS> \ --rpc-url https://garfield-testnet.zircuit.com ``` {% endtab %} {% endtabs %} Get transaction details: {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash cast tx <TRANSACTION_HASH> \ --rpc-url https://mainnet.zircuit.com ``` {% endtab %} {% tab title="Garfield Testnet" %} ```bash cast tx <TRANSACTION_HASH> \ --rpc-url https://garfield-testnet.zircuit.com ``` {% endtab %} {% endtabs %} {% endstep %} {% step %} **Verifying Contracts** After doing programmatic interactions with the smart contract, you can also verify the contract using `forge`. {% tabs %} {% tab title="Zircuit Mainnet" %} ```bash forge verify-contract <CONTRACT_ADDRESS> <SOURCE_FILE>:<CONTRACT_NAME> \ --chain-id 48900 \ --verifier sourcify \ --verifier-url https://sourcify.dev/server ``` [https://explorer.zircuit.com/address](https://explorer.zircuit.com/address/)/\<CONTRACT\_ADDRESS> {% endtab %} {% tab title="Garfield Testnet" %} ```bash forge verify-contract <CONTRACT_ADDRESS> <SOURCE_FILE>:<CONTRACT_NAME> \ --chain-id 48898 \ --verifier sourcify \ --verifier-url https://sourcify.dev/server ``` <https://explorer.garfield-testnet.zircuit.com/address>/\<CONTRACT\_ADDRESS> {% endtab %} {% endtabs %} {% endstep %} {% step %} **Advanced Features** **Running Tests** Foundry includes a powerful testing framework: ```bash # Run all tests forge test # Run tests with verbose output forge test -vvv # Run specific test forge test --match-test testIncrement ``` **Code Coverage** Generate test coverage reports: ```bash forge coverage ``` **Gas Reporting** Get detailed gas usage reports: ```bash forge test --gas-report ``` **Gas Reporting** Get detailed gas usage reports: ```bash forge test --gas-report ``` {% endstep %} {% endstepper %} # Run Zircuit {% hint style="info" icon="triangle-exclamation" %} ## Note that [SLS](https://docs.zircuit.com/info/architecture/sls) is not enabled while we [focus](https://www.zircuit.com/blog/a-new-chapter-for-zircuit-from-l2-to-defi) on Zircuit Finance. Zircuit Finance does not rely on the Zircuit chain. {% endhint %} ## Overview Run your own Public Zircuit Node or Partner Zircuit Node on Mainnet or Garfield-Testnet. This guide covers setup, configuration, and operations for both public and partner node operators. ### Prerequisites #### System Requirements * **OS**: Linux or macOS * **Python**: 3.11 or higher * **Storage**: * **Type**: Solid State * **Garfield-Testnet**: 200-300 GB initially (grows over time as network progresses) * **Mainnet**: 750-1000 GB initially (grows over time as network progresses) * **CPU**: 4 cores recommended * **RAM**: 16 GB recommended * **Software**: * Docker + Docker Compose (required), * lz4 (for snapshot decompression, required), * aria2c (for accelerating snapshot downloads, optional but **strongly recommended**) * sha256 utils (for verifying snapshot integrity, required) For testing on a desktop computer, both Docker Desktop (with Compose extension) and Podman Desktop (with Compose extension) should work. ## Quick Start ### Get the Script Make a new directory and download the node controller script to it: ```bash mkdir -p my-public-zircuit-node cd my-public-zircuit-node curl -sS https://bootstrap.mainnet.zircuit.com/zircuit -o zircuit chmod +x zircuit ``` {% hint style="info" %} The script doesn't support to be run as the `root` user. Use a regular user instead. {% endhint %} ### Initialize as a Public Node #### **Testnet (default)** ```bash ./zircuit init ``` #### **Mainnet** ```bash ./zircuit init --network mainnet ``` The above commands will: * Synchronize the latest chaindata [snapshot](#snapshots). * Generate node identity files (JWT secret, P2P key). * Create
프로젝트로 돌아가기