# Table of Contents - [Index - ApeChain Docs](#index-apechain-docs) - [Add ApeChain to Metamask - ApeChain Docs](#add-apechain-to-metamask-apechain-docs) - [Run Node - ApeChain Docs](#run-node-apechain-docs) - [Contract Decoding - ApeChain Docs](#contract-decoding-apechain-docs) - [APIs - ApeChain Docs](#apis-apechain-docs) - [Analytics - ApeChain Docs](#analytics-apechain-docs) - [AI Agents - ApeChain Docs](#ai-agents-apechain-docs) - [Contract Information - ApeChain Docs](#contract-information-apechain-docs) - [Contract Information - ApeChain Docs](#contract-information-apechain-docs) - [Block Explorers - ApeChain Docs](#block-explorers-apechain-docs) - [Faucets - ApeChain Docs](#faucets-apechain-docs) - [Data Indexers - ApeChain Docs](#data-indexers-apechain-docs) - [Overview of LayerZero's OFT Standard: - ApeChain Docs](#overview-of-layerzero-s-oft-standard-apechain-docs) - [How to Verify a Smart Contract on Apechain Curtis Using Sourcify - ApeChain Docs](#how-to-verify-a-smart-contract-on-apechain-curtis-using-sourcify-apechain-docs) - [What is Espresso? - ApeChain Docs](#what-is-espresso-apechain-docs) - [Storage - ApeChain Docs](#storage-apechain-docs) - [Oracles - ApeChain Docs](#oracles-apechain-docs) - [Feedback - ApeChain Docs](#feedback-apechain-docs) - [Verifying a Smart Contract on Apechain - ApeChain Docs](#verifying-a-smart-contract-on-apechain-apechain-docs) - [Connect - ApeChain Docs](#connect-apechain-docs) - [Gas Estimator - ApeChain Docs](#gas-estimator-apechain-docs) - [Safes - ApeChain Docs](#safes-apechain-docs) - [Remix - ApeChain Docs](#remix-apechain-docs) - [APE Builder by Sequence - ApeChain Docs](#ape-builder-by-sequence-apechain-docs) - [Node Providers - ApeChain Docs](#node-providers-apechain-docs) - [Resources - ApeChain Docs](#resources-apechain-docs) - [User Onboarding - ApeChain Docs](#user-onboarding-apechain-docs) - [Buildkit - ApeChain Docs](#buildkit-apechain-docs) - [NFT Shadows - ApeChain Docs](#nft-shadows-apechain-docs) - [Architecture - ApeChain Docs](#architecture-apechain-docs) - [Foundry - ApeChain Docs](#foundry-apechain-docs) - [Verified Random Number Generator (vRNG) - ApeChain Docs](#verified-random-number-generator-vrng-apechain-docs) - [Hardhat - ApeChain Docs](#hardhat-apechain-docs) - [ApePortal FAQ - ApeChain Docs](#apeportal-faq-apechain-docs) - [Subgraphs - ApeChain Docs](#subgraphs-apechain-docs) --- # Index - ApeChain Docs About ApeChain[](https://docs.apechain.com/#apechain) ------------------------------------------------ ![orbit](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fape_sky.489fde9b.png&w=3840&q=75) **ApeChain provides developers and users with the best possible experience on the blockchain by focusing on ecosystem discovery, unique web3 rails, and top of funnel exposure.** * * * ApeChain is a dedicated infrastructure layer to power the ApeCoin ecosystem. ApeChain utilizes $APE as its native gas token. This integration significantly enhances $APE's utility, fostering a robust and dynamic economy driven by $APE, and positioning ApeChain as a premier platform. ApeChain at its core is an Arbitrum Orbit chain. --- # Add ApeChain to Metamask - ApeChain Docs Add to your wallet Add ApeChain to Metamask ======================== Using the ApeChain Hub Page[](https://docs.apechain.com/metamask#using-the-apechain-hub-page) ---------------------------------------------------------------------------------------------- 1. Navigate to the hub for [Testnet (opens in a new tab)](https://curtis.hub.caldera.xyz/) or [Mainnet (opens in a new tab)](https://apechain.hub.caldera.xyz/) 2. Click the **Connect** button in the _Your Wallet_ section, and you will be prompted to switch to the ApeChain Network 💡 When you click on the Connect button, please check the wallet extension icon and ensure you grant access to switch networks. Connect with the ApeChain AI[](https://docs.apechain.com/metamask#connect-with-the-apechain-ai) ------------------------------------------------------------------------------------------------ You can also have the Apechain AI bot automatically add the network details to your MetaMask. Simply click on the bot, go to the "Chain Info" tab at the top right, and then click on "Add to Wallet." ![hubpage](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fchain_info.5270ca84.png&w=3840&q=75) Manually add to your Metamask wallet[](https://docs.apechain.com/metamask#manually-add-to-your-metamask-wallet) ---------------------------------------------------------------------------------------------------------------- You can add the network with the following details: | Mainnet | Details | | --- | --- | | Network Name | ApeChain | | RPC URL | [https://apechain.calderachain.xyz/http (opens in a new tab)](https://apechain.calderachain.xyz/http) | | Chain ID | 33139 | | Currency Symbol | APE | | Block Explorer | [https://apechain.calderaexplorer.xyz/ (opens in a new tab)](https://apechain.calderaexplorer.xyz/) | * * * | Testnet | Details | | --- | --- | | Network Name | Curtis | | RPC URL | [https://curtis.rpc.caldera.xyz/http (opens in a new tab)](https://curtis.rpc.caldera.xyz/http) | | Chain ID | 33111 | | Currency Symbol | APE | | Block Explorer | [https://curtis.explorer.caldera.xyz/ (opens in a new tab)](https://curtis.explorer.caldera.xyz/) | --- # Run Node - ApeChain Docs Run a Node About ApeChain RPC[](https://docs.apechain.com/run-node#about-apechain-rpc) ---------------------------------------------------------------------------- Apechain RPC (Remote Procedure Call) is a JSON-RPC interface that allows developers and applications to interact with Apechain nodes programmatically. It enables operations such as querying blockchain data (e.g., balances, blocks, and transactions) and submitting write operations (e.g., deploying smart contracts or sending transactions). Being EVM-compatible, Apechain RPC supports Ethereum-like methods, making it easy to use tools like ethers.js or web3.js for interaction. Running a replica node for ApeChain Mainnet[](https://docs.apechain.com/run-node#running-a-replica-node-for-apechain-mainnet) ------------------------------------------------------------------------------------------------------------------------------ Please check out the [latest (v3.5.6) repository (opens in a new tab)](https://github.com/ConstellationCrypto/replica-guide-apechain-mainnet) for an example of how to spin up a node locally. Simply run `docker-compose up` to bring a replica node up locally. The `nodeConfig` file is prepopulated with apechain parameters. The current setup uses a public rpc url for the Arbitrum One rpc and stores node data in docker volume. Replace the arbitrum one rpc url with your own to avoid being rate limited. 💡 Syncing can take up to a few hours. ### Docker Images[](https://docs.apechain.com/run-node#docker-images) `public.ecr.aws/i6b2w2n6/nitro-node:apechain-v3.5.6` ### Existing RPC Endpoints[](https://docs.apechain.com/run-node#existing-rpc-endpoints) HTTP endpoint: `https://rpc.apechain.com/http` WS endpoint: `wss://rpc.apechain.com/ws` Snapshot guide[](https://docs.apechain.com/run-node#snapshot-guide) -------------------------------------------------------------------- To bring your replica node up to sync, use the following available snapshot: [Snapshot taken Sep 22, 2025 (opens in a new tab)](https://caldera-chain-data-snapshots.s3.us-west-2.amazonaws.com/exported-snapshots/nitro-apechain/nitro-apechain-2025-Sep-22.tar) Running a replica node for Curtis[](https://docs.apechain.com/run-node#running-a-replica-node-for-curtis) ---------------------------------------------------------------------------------------------------------- Download the zipped repository below for an out-of-the-box example of how to spin up a node locally. [nitro-replica-curtis.zip (opens in a new tab)](https://misc-bucket.caldera.xyz/nitro-replica-curtis-files.zip) 💡 Syncing can take up to a few hours. ### Using the Repo[](https://docs.apechain.com/run-node#using-the-repo) The repo is set up to easily run curtis testnet replica nodes. Simply run `docker-compose up` from the root of the repository to bring a replica node up locally. The docker image for curtis testnet is hosted in a public docker repo: `public.ecr.aws/i6b2w2n6/nitro-node:curtis3` The `nodeConfig` file included in the repository is prepopulated with curtis testnet parameters. The current setup uses a public rpc url for the Arbitrum Sepolia rpc and stores node data in ad Docker volume. It is recommended to replace the Arbitrum Sepolia RPC URL in `docker-compose.yml` with your own private url to avoid ratelimiting issues, it's advised to use your private PRC URL instead of the default public one. By default, this value is set to Arbitrum's public RPC url. ### Docker Images[](https://docs.apechain.com/run-node#docker-images-1) `public.ecr.aws/i6b2w2n6/nitro-node:curtis3` ### Existing RPC Endpoints[](https://docs.apechain.com/run-node#existing-rpc-endpoints-1) HTTP endpoint: `https://curtis.rpc.caldera.xyz/http` WS endpoint: `wss://curtis.rpc.caldera.xyz/ws` --- # Contract Decoding - ApeChain Docs Contract Decoding Contract Decoding ================= Decoding a contract means giving Dune your contract’s ABI, so it can turn raw blockchain data into easy-to-read tables of events and actions. For builders on ApeChain, decoding your contract lets you and others instantly see mints, trades, and user activity in clear dashboards — making your project easier to track, analyze, and showcase across the ApeChain ecosystem. Decode your first contract on Dune[](https://docs.apechain.com/contract-decoding#decode-your-first-contract-on-dune) --------------------------------------------------------------------------------------------------------------------- 1. Go to [https://dune.com/contracts/new (opens in a new tab)](https://dune.com/contracts/new) 2. Select the blockchain where your contract is deployed. 3. In the contract address field, enter your deployed contract address. 4. Give the project a name (e.g., this could be the name of your NFT collection). The project name needs to be all lowercase, no spaces, use underscore if needed. 5. Leave the contract name as is if unknown. 6. Enable bytecode matching: If there is a project that is launching on multiple chains this option allows Dune to automatically decode and add these contracts as they are deployed. 7. Decode other contracts created by the same factory: This is critical, especially for DeFi and NFT projects. Essentially puts all of the contracts created by one factory in the same table for easy querying. 8. Contract ABI can be found at the bottom of the contract tab on ApeScan.io if the contract is verified. Example contract ABI for wAPE token can be found here: [https://apescan.io/address/0x48b62137edfa95a428d35c09e44256a739f6b557#code (opens in a new tab)](https://apescan.io/address/0x48b62137edfa95a428d35c09e44256a739f6b557#code) 9. Once submitted, it can take up to 24 hours for Dune to complete decoding. 10. If you'd like to learn more about Dune, check out their docs here [https://docs.dune.com/web-app/decoding/decoding-contracts#decoding-contracts (opens in a new tab)](https://docs.dune.com/web-app/decoding/decoding-contracts#decoding-contracts) . --- # APIs - ApeChain Docs APIs APIs ==== Dune Sim[](https://docs.apechain.com/apis#dune-sim) ---------------------------------------------------- [Dune's Sim APIs (opens in a new tab)](https://sim.dune.com/) provide a comprehensive toolkit for developers needing fast, reliable access to realtime, EVM and SVM blockchain data. Engineered for speed and an optimal developer experience, Sim APIs offer an intuitive way to query extensive onchain information through straightforward REST APIs: * [Activity API (opens in a new tab)](https://docs.sim.dune.com/evm/activity) : Access a chronological feed of onchain activity for any EVM address, including transfers and decoded contract interactions. * [Balances API (opens in a new tab)](https://docs.sim.dune.com/evm/balances) : Retrieve realtime native and ERC20 token balances, complete with metadata and USD valuations. * [Token Info API (opens in a new tab)](https://docs.sim.dune.com/evm/token-info) : Obtain detailed metadata and realtime price information for native assets or ERC20 tokens. * [Collectibles API (opens in a new tab)](https://docs.sim.dune.com/evm/collectibles) : Fetch NFT (ERC721 and ERC1155) balances and their attributes for an address. * [Transactions API (opens in a new tab)](https://docs.sim.dune.com/evm/transactions) : Get granular details for specific transactions, including block information and gas data. * [Token Holders API (opens in a new tab)](https://docs.sim.dune.com/evm/token-holders) : Discover token distribution for ERC20 or ERC721 tokens, ranked by wallet value. In partnership with ApeChain, Dune's Sim APIs give developers direct and powerful access to ApeChain's onchain data. This enables ApeChain developers to efficiently build and enhance a variety of apps, from advanced wallets and dApps to sophisticated analytical tools, by using realtime insights into token balances, NFT data, account activity, transaction specifics, and detailed token metadata directly from the ApeChain network. To get started, visit the [Sim API Docs (opens in a new tab)](https://docs.sim.dune.com/) . --- # Analytics - ApeChain Docs Analytics Analytics ========= Sequence[](https://docs.apechain.com/analytics#sequence) --------------------------------------------------------- Sequence’s [analytics (opens in a new tab)](https://docs.sequence.xyz/solutions/builder/analytics) feature allows users to easily track key metrics without additional work. By using Sequence SDKs/APIs, analytics events are sent to Databeat for real-time storage and visualization. When you use Sequence, via our SDKs, to build your application, you can see key insights in Sequence Builder. You don’t need to do any additional work to see valuable metrics about your project, such as the number of connected wallets, active users or daily transaction requests. When requests are made with Sequence SDKs/APIs, analytics events are fired and sent to our internal analytics system, Databeat. Databeat anonymizes the data and stores it in a secure database designed for high-volume, real-time applications. The metrics can be queried from the database, in real-time, for your project and presented in insightful visualizations. Allium[](https://docs.apechain.com/analytics#allium) ----------------------------------------------------- [Allium (opens in a new tab)](https://www.allium.so/) specializes in blockchain data infrastructure, offering tools that make it easier for organizations to analyze and manage data. Their platform provides real-time data access, enhanced data organization, and advanced alerting features, helping teams quickly gain insights and monitor blockchain activities. In the ApeChain collaboration, Allium's role is to ensure the network can efficiently handle complex data queries and provide real-time insights, supporting developers and keeping the ecosystem running smoothly. --- # AI Agents - ApeChain Docs AI Agents AI Agents ========= Ape Agent by Flow AI[](https://docs.apechain.com/ai-agents#ape-agent-by-flow-ai) --------------------------------------------------------------------------------- [Ape Agent (opens in a new tab)](https://flowai.xyz/agent/apecoin) is an AI agent powered by [Flow AI (opens in a new tab)](https://flowai.xyz/) that offers a rich set of tools to interact with the Ape ecosystem, including Apecoin ($APE), ApeChain, BananaBill, and everything related to the Bored Ape Yacht Club. It's like talking to [GordonGoner (opens in a new tab)](https://x.com/GordonGoner) , you can ask questions about onchain and offchain APE ecosystem: * Market Insights: Live prices and on-chain data from CoinGecko and Etherscan. * NFT Metrics: Real-time data from OpenSea (MagicEden is in progress). * Governance Tracking: Direct integration with Discourse forums and Snapshot votes. * Community Feeds: Updates from Twitter, Discord, and Discourse forums. * Apecoin Metrics: Yield tracking and treasury analytics. * Ecosystem Resources: Quick links to ApeChain dApps. Here's a video demonstrating how to use the Ape Agent: --- # Contract Information - ApeChain Docs Contracts Mainnet Contract Information Apechain Contracts[](https://docs.apechain.com/contracts/Mainnet/contract-information#apechain-contracts) ---------------------------------------------------------------------------------------------------------- You can visit the [Hub (opens in a new tab)](https://apechain.hub.caldera.xyz/) , where you'll find Rollup Files in the details section. These files include both a nodeConfig.json file and a contracts.json file. ### ChainInfo[](https://docs.apechain.com/contracts/Mainnet/contract-information#chaininfo) | Name | Address | | --- | --- | | parentChainId | `42161` | | nativeToken | `0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98` | ### CoreContracts[](https://docs.apechain.com/contracts/Mainnet/contract-information#corecontracts) | Name | Address | | --- | --- | | rollup | `0x374de579AE15aD59eD0519aeAf1A23F348Df259c` | | inbox | `0x1B98e4ED82Ee1a91A65a38C690e2266364064D15` | | outbox | `0x4F405BA65291063d8A524c2bDf55d4e67405c2aF` | | adminProxy | `0x1E5f8ff72895aEa53DD62b590dA51E92dC75b507` | | sequencerInbox | `0xE6a92Ae29E24C343eE66A2B3D3ECB783d65E4a3C` | | bridge | `0x6B71AFb4b7725227ab944c96FE018AB9dc0434b8` | | utils | `0xaB36aec5517C346D21b9C19429BAA5aa87D17fCa` | | validatorWalletCreator | `0x5a6C98F6A60BDC02cE4d8AD43b4Fc88Fe5b38856` | ### TokenBridgeContract[](https://docs.apechain.com/contracts/Mainnet/contract-information#tokenbridgecontract) #### L2Contracts[](https://docs.apechain.com/contracts/Mainnet/contract-information#l2contracts) | Name | Address | | --- | --- | | customGateway | `0xEd543dA6fE33cceE50DC024b78C27959235D0ab0` | | multicall | `0x411f8A148e448bBe75382d4FFABee0796484f3c6` | | proxyAdmin | `0x1E5f8ff72895aEa53DD62b590dA51E92dC75b507` | | router | `0xD57Df5C2Dc2D60307a74944191f2aA5B7BD4a700` | | standardGateway | `0xB603a1C07A11945bFe4855347c88583e31b8ddB0` | | weth | `0x0000000000000000000000000000000000000000` | | wethGateway | `0x0000000000000000000000000000000000000000` | #### L3Contracts[](https://docs.apechain.com/contracts/Mainnet/contract-information#l3contracts) | Name | Address | | --- | --- | | customGateway | `0x49607221AF038229cEc6c85DB37a652E00226D29` | | multicall | `0x350186513FB2C148A50439311533656EF8096D9C` | | proxyAdmin | `0x965a8220D41A031b1F71d94feFBf13dE4f686B33` | | router | `0x31eFB847d3f7A0C9Ba1364a6423aEa0a7a60BF3C` | | standardGateway | `0xf9710169D2f3524E7Bf068F6DDF6b2cc65D38a14` | | weth | `0x0000000000000000000000000000000000000000` | | wethGateway | `0x0000000000000000000000000000000000000000` | --- # Contract Information - ApeChain Docs Contracts Testnet Contract Information Apechain Contracts[](https://docs.apechain.com/contracts/Testnet/contract-information#apechain-contracts) ---------------------------------------------------------------------------------------------------------- You can visit the [Hub (opens in a new tab)](https://curtis.hub.caldera.xyz/) , where you'll find Rollup Files in the details section. These files include both a nodeConfig.json file and a contracts.json file. ### ChainInfo[](https://docs.apechain.com/contracts/Testnet/contract-information#chaininfo) | Name | Address | | --- | --- | | parentChainId | `421614` | | nativeToken | `0x6Cb8Cc1e323357Af5da49d90FCb7160B7f09e6Cd` | ### CoreContracts[](https://docs.apechain.com/contracts/Testnet/contract-information#corecontracts) | Name | Address | | --- | --- | | rollup | `0x276b8853606a63954A0FD903bb319AbCd9263830` | | inbox | `0x990A3402F3358A1Ac9886c42d12A5C47aD97cb94` | | outbox | `0x7B5fda237527B280224000A275eAa1B8b8149334` | | adminProxy | `0x71008F82Ea21fF8c29B1A46E838bD3DB38c10f1e` | | sequencerInbox | `0x3A61142c49F49C3C58eF221C672C27211d03d060` | | bridge | `0x9DCD26d4947204CC541833d91Ca937859d5379F4` | | utils | `0x09e810fda0FD130b95009e5C831aCe0069437473` | | validatorWalletCreator | `0x0f5ce50Db32F7Ea8b43da72dba66C42267b101bD` | ### TokenBridgeContracts[](https://docs.apechain.com/contracts/Testnet/contract-information#tokenbridgecontracts) #### L2Contracts[](https://docs.apechain.com/contracts/Testnet/contract-information#l2contracts) | Name | Address | | --- | --- | | customGateway | `0x28B5340d3a9366bf6B85145AB2067E97c1Fd1B73` | | multicall | `0x3AFeb1Ea760EED35D224C531D531C30eC6aE13e5` | | proxyAdmin | `0x71008F82Ea21fF8c29B1A46E838bD3DB38c10f1e` | | router | `0xc5225F78Fd279a080508B946B15216B8Bc896a42` | | standardGateway | `0xf97A37feE94A7E2f28403AF8e1731393F91479c0` | | weth | `0x0000000000000000000000000000000000000000` | | wethGateway | `0x0000000000000000000000000000000000000000` | #### L3Contracts[](https://docs.apechain.com/contracts/Testnet/contract-information#l3contracts) | Name | Address | | --- | --- | | customGateway | `0x7b5DD6eD959322bDFd8c92A05A91FB15c2502e21` | | multicall | `0x4dA8Dd72d43d7e26ACe1188d6ACa52d1b3CD3F65` | | proxyAdmin | `0xD2a915cf6de1250cadfD657748D3ABc1291A270C` | | router | `0xCF6febF2eE4382D592DC194DDB0b5A853d4AC794` | | standardGateway | `0x5b6cbA57e0BB050CBD1145C8B2C70BC80d997DA5` | | weth | `0x0000000000000000000000000000000000000000` | | wethGateway | `0x0000000000000000000000000000000000000000` | --- # Block Explorers - ApeChain Docs Block Explorers Block Explorers =============== Apescan[](https://docs.apechain.com/block-explorers#apescan) ------------------------------------------------------------- | Network | Supported | Link | | --- | --- | --- | | Mainnet | ✅ | [https://apescan.io/ (opens in a new tab)](https://apescan.io/) | | Curtis Testnet | ✅ | [https://curtis.apescan.io/ (opens in a new tab)](https://curtis.apescan.io/) | [ApeScan (opens in a new tab)](https://apescan.io/) , powered by [Etherscan (opens in a new tab)](https://etherscan.io/) is the primary block explorer for ApeChain. It allowing users to track transactions, view wallets, and interact with smart contracts. It simplifies monitoring ApeCoin activities and supports developers with tools for contract verification and dApp interaction​s. Note: ApeScan **DOES NOT SUPPORT** NFT metadata and images on Curtis Testnet yet. Blockscout[](https://docs.apechain.com/block-explorers#blockscout) ------------------------------------------------------------------- | Network | Supported | Link | | --- | --- | --- | | Mainnet | ✅ | [https://apechain.calderaexplorer.xyz/ (opens in a new tab)](https://apechain.calderaexplorer.xyz/) | | Curtis Testnet | ✅ | [https://curtis.explorer.caldera.xyz/ (opens in a new tab)](https://curtis.explorer.caldera.xyz/) | [Blockscout (opens in a new tab)](https://www.blockscout.com/) is a widely-used, open-source blockchain explorer that allows users to explore and interact with EVM-compatible blockchains. Blockscout provides a range of features, such as transaction verification, smart contract interaction, and comprehensive data analytics. In its collaboration with ApeChain, Blockscout allows users and developers within the ApeCoin ecosystem to explore transactions, interact with smart contracts, and monitor on-chain activities. By leveraging Blockscout’s open-source framework, ApeChain ensures that the community has access to an efficient tool for exploration and analysis, enhancing the overall user experience on the platform. OKX Explorer[](https://docs.apechain.com/block-explorers#okx-explorer) ----------------------------------------------------------------------- [OKX (opens in a new tab)](https://www.okx.com/web3/explorer) hosts an ApeChain explorer tool, allowing users to view real-time data on transactions, tokens, and other on-chain activities, which helps streamline tracking and transparency. OKX’s infrastructure, including its blockchain explorer, bridges, and Web3 tools, supports ApeChain’s goal of expanding its reach and functionality within the Web3 ecosystem​. | Network | Supported | Link | | --- | --- | --- | | Mainnet | ✅ | [https://www.okx.com/web3/explorer/apechain (opens in a new tab)](https://www.okx.com/web3/explorer/apechain) | --- # Faucets - ApeChain Docs Faucets Faucets ======= Caldera[](https://docs.apechain.com/faucet#caldera) ---------------------------------------------------- To request funds from the ApeChain testnet faucet: 1. Navigate to the _Faucet Section_ on the [Hub Page (opens in a new tab)](https://curtis.hub.caldera.xyz/) 2. Enter your wallet address 3. Click the **Request** button After a few seconds, you will see a deposit of Testnet APE in your wallet! The current limit when requesting from the Caldera faucet is 1 APE ![faucet](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ffaucet.0702767b.png&w=1920&q=75) --- # Data Indexers - ApeChain Docs Data Indexers Data Indexers ============= Sequence[](https://docs.apechain.com/data-indexers#sequence) ------------------------------------------------------------- The [Sequence Indexer (opens in a new tab)](https://docs.sequence.xyz/api-references/indexer/overview) is a powerful tool that can be used to build wallets, games, and dapps that need to query on-chain data. In addition, it utilizes built in-house, next-generation, LSM-tree based databases to store the data. It makes it super fast to query and index data. The data is available in real-time with low latency. You can query it using a simple REST API or one of our SDKs. The Indexer API allows you to query all token balances, history and other information for all Ethereum compatible chains. In order to make it one go to place for all your token data needs, we have included [Sequence Metadata (opens in a new tab)](https://docs.sequence.xyz/api-references/metadata/overview) support for all tokens. This means that you can easily render tokens in your apps, games, or wallets without the need to fetch metadata from a separate API. Reservoir[](https://docs.apechain.com/data-indexers#reservoir) --------------------------------------------------------------- [Reservoir (opens in a new tab)](https://reservoir.tools/) offers APIs and tools for seamless NFT trading, data access, and marketplace integration, making it easy for developers to add NFT features like buying, selling, and real-time market data to their apps. In collaboration with ApeChain, Reservoir provides the necessary tools for NFT trading and data management, enabling developers to efficiently build and run NFT marketplaces. This partnership enhances ApeChain's capabilities for cross-marketplace trading, aggregated liquidity, and advanced data analytics, supporting the growing demand for NFTs and Web3 gaming. Etherscan[](https://docs.apechain.com/data-indexers#etherscan) --------------------------------------------------------------- [Etherscan (opens in a new tab)](https://etherscan.io/) is working with ApeChain by supporting contract verification and blockchain exploration for our L3 network. This integration not only helps ensure contract authenticity, but also provides developers with the tools they need to interact with the ApeChain network efficiently. By setting up custom network configurations, ApeChain can leverage Etherscan’s tools for tracking transactions, managing contracts, and ensuring activities on the chain are visible and verifiable​. --- # Overview of LayerZero's OFT Standard: - ApeChain Docs APE OFT Overview of LayerZero's OFT Standard: ===================================== The [Omnichain Fungible Token (OFT) Standard (opens in a new tab)](https://docs.layerzero.network/v2/developers/evm/onft/quickstart) enables fungible tokens to exist across multiple blockchains while maintaining a unified supply. The OFT standard works by debiting an amount of tokens from a sender on the source chain and crediting the same amount of tokens to a receiver on the destination chain. $APE, the native gas currency of ApeChain network, is deployed across multiple blockchains using LayerZero's OFT standard. At the moment, the $APE OFT token is available on the following networks: * ApeChain * Ethereum * Arbitrum * Solana * HyperEVM * Binance Smart Chain Relevant Contracts[](https://docs.apechain.com/ape-oft#relevant-contracts) --------------------------------------------------------------------------- | Network | Address | Contract Type | Scanner | | --- | --- | --- | --- | | ApeChain | 0xe4103e80c967f58591a1d7cA443ed7E392FeD862 | OrbitNativeOFTAdapter | [https://apechain.calderaexplorer.xyz/address/0xe4103e80c967f58591a1d7cA443ed7E392FeD862 (opens in a new tab)](https://apechain.calderaexplorer.xyz/address/0xe4103e80c967f58591a1d7cA443ed7E392FeD862) | | Ethereum | 0x4d224452801aced8b2f0aebe155379bb5d594381 | ERC-20 | [https://etherscan.io/token/0x4d224452801aced8b2f0aebe155379bb5d594381 (opens in a new tab)](https://etherscan.io/token/0x4d224452801aced8b2f0aebe155379bb5d594381) | | Arbitrum | 0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98 | ERC-20 | [https://arbiscan.io/token/0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98 (opens in a new tab)](https://arbiscan.io/token/0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98) | | Solana | C1MHyoTJpRTeS9AQCyspNVu2EWAYCZwmJ1jNkEArFP1f | SPL | [https://solscan.io/token/C1MHyoTJpRTeS9AQCyspNVu2EWAYCZwmJ1jNkEArFP1f (opens in a new tab)](https://solscan.io/token/C1MHyoTJpRTeS9AQCyspNVu2EWAYCZwmJ1jNkEArFP1f) | | HyperEVM | 0xab11329560Fa9C9c860Bb21A9342215a1265BBB0 | ERC-20 | [https://hyperevmscan.io/token/0xab11329560fa9c9c860bb21a9342215a1265bbb0 (opens in a new tab)](https://hyperevmscan.io/token/0xab11329560fa9c9c860bb21a9342215a1265bbb0) | | BSC | 0x8f86a15EC17cb3369d8b3E666dAdBC11daA82b79 | BEP-20 | [https://bscscan.com/token/0x8f86a15ec17cb3369d8b3e666dadbc11daa82b79 (opens in a new tab)](https://bscscan.com/token/0x8f86a15ec17cb3369d8b3e666dadbc11daa82b79) | | Monad | 0x6a7e3f839382fbb6a6131d4aae864aaeb362292d | ERC-20 | [https://monadscan.com/token/0x6a7e3f839382fbb6a6131d4aae864aaeb362292d (opens in a new tab)](https://monadscan.com/token/0x6a7e3f839382fbb6a6131d4aae864aaeb362292d) | --- # How to Verify a Smart Contract on Apechain Curtis Using Sourcify - ApeChain Docs Contracts contract-verification Sourcify How to Verify a Smart Contract on Apechain Curtis Using Sourcify ================================================================ Introduction[](https://docs.apechain.com/contracts/contract-verification/sourcify#introduction) ------------------------------------------------------------------------------------------------ Verifying a smart contract on the blockchain is crucial to ensuring transparency, security, and simplifying interaction for both users and developers. In this guide, we'll walk you through the process of verifying your smart contract on the Apechain Curtis network using Foundry and the Sourcify verifier. Prerequisites[](https://docs.apechain.com/contracts/contract-verification/sourcify#prerequisites) -------------------------------------------------------------------------------------------------- Before you begin the verification process, make sure you have the following: * **Forge Installed**: This is essential for compiling, deploying, and verifying your smart contract. You can also follow this guide to install if you haven't. * **Ready Your Smart Contract**: Ensure your smart contract is ready to be deployed on the Curtis network. If it is already deployed then just get the contract address ready. Verifying Your Contract[](https://docs.apechain.com/contracts/contract-verification/sourcify#verifying-your-contract) ---------------------------------------------------------------------------------------------------------------------- Once your contract is deployed or ready, you can proceed with verification using Sourcify. Replace placeholders in the following commands with your actual contract details. For contract deployment and verification: ### Mainnet[](https://docs.apechain.com/contracts/contract-verification/sourcify#mainnet) forge create --rpc-url https://apechain.calderachain.xyz/http --private-key YOUR-PRIVATE-KEY src/FileName.sol:ContractName --verify --verifier sourcify ### Testnet[](https://docs.apechain.com/contracts/contract-verification/sourcify#testnet) forge create --rpc-url https://curtis.rpc.caldera.xyz/http --private-key YOUR-PRIVATE-KEY src/FileName.sol:ContractName --verify --verifier sourcify This command will deploy your contract to the Apechain Testnet or Mainnet depending on the command you run and then immediately begin the verification process by submitting your contract's source code and metadata to Sourcify. Once verified, your contract's source will be publicly accessible and associated with its on-chain address. You should see a response similar to the following after successful verification: ![Deployed](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fverified.8919048c.png&w=3840&q=75) If your smart contract is already deployed and you just want to verify it, then all you need to do is to open your terminal and navigate to the the root directory of your deployed contract’s project run the following command below and replace YOUR-CONTRACT-ADDRESS with the actual contract address you want to verify. ### Testnet[](https://docs.apechain.com/contracts/contract-verification/sourcify#testnet-1) forge verify-contract Your-Contract-Address src/FileName.sol:ContractName --chain-id 33111 --verifier sourcify ### Mainnet[](https://docs.apechain.com/contracts/contract-verification/sourcify#mainnet-1) forge verify-contract Your-Contract-Address src/FileName.sol:ContractName --chain-id 33139 --verifier sourcify This will submit your deployed contract for verification without redeploying. Conclusion[](https://docs.apechain.com/contracts/contract-verification/sourcify#conclusion) -------------------------------------------------------------------------------------------- Verifying your smart contract ensures transparency and boosts the credibility of your project. It also makes the contract more accessible to users and developers by associating the source code with the on-chain address. Following the steps in this guide helps create a more secure ecosystem. --- # What is Espresso? - ApeChain Docs Cross-Chain Espresso’s fast finality provides a new era of applications that can be built. What is Espresso? ================= **Espresso is a decentralized network that provides fast, deterministic finality for blockchain transactions**. It confirms transactions quickly and guarantees that once a transaction is finalized by Espresso, it cannot be reverted. The Concept of Finality ======================= Finality is the point at which a transaction can no longer be reverted. On a rollup (L2/L3), **finality typically occurs when the transaction is included in a batch and posted** to the parent chain (usually an L1). How often this happens depends on the rollup, but in practice it often takes 10–15 minutes or more. Until that point, applications must assume that the **transaction could be reverted**. With Espresso, applications don’t have to wait for the batch to be posted to the parent chain. Transactions confirmed by the **Espresso Network reach finality within seconds**, backed by Espresso’s Byzantine Fault Tolerant (BFT) consensus. Once finalized by Espresso, a transaction is safe to act on immediately. What Kind of L2/L3 Applications Does Espresso Enable? ===================================================== Fast finality doesn’t just make existing apps better, it enables entirely new designs. 1\. Cross-Chain Bridges[](https://docs.apechain.com/cross-chain#1-cross-chain-bridges) --------------------------------------------------------------------------------------- Consider an application that moves assets from one chain (the source chain) to another (the destination chain), for example from ApeChain to Rari Chain. To safely release funds on the destination chain, **the application must be certain that the source-chain transaction will not be reverted**. Today, that certainty usually only arrives once the transaction is finalized on the parent chain—often 15 minutes or more. With Espresso, the **destination chain can act within seconds**. Once a transaction is confirmed by the Espresso Network, it is final and cannot be reverted, allowing funds to be released immediately. This model can be applied to existing cross-chain protocols such as Relay or Across. Solvers (the entities that front liquidity on the destination chain) can safely release funds as soon as they observe Espresso finality, dramatically improving latency without weakening security. 2\. Cross-Chain NFT Platforms[](https://docs.apechain.com/cross-chain#2-cross-chain-nft-platforms) --------------------------------------------------------------------------------------------------- Espresso also enables new kinds of NFT minting experiences–including those in which bridging is not needed at all. Imagine an NFT deployed on ApeChain, but **users want to pay from another chain**, such as Rari Chain. Traditionally, this requires users to bridge funds manually, creating friction and liquidity risk. To mint the NFT on the destination chain, the application must be sure that the payment transaction on the source chain is final and irreversible. Espresso provides that guarantee within seconds, allowing the NFT mint to happen safely and immediately without the need for an additional bridging step. The Espresso team has already built **Presto, a cross-chain NFT minting framework** that follows this pattern. While Presto was initially designed for NFTs, the underlying architecture can be generalized to trigger arbitrary cross-chain actions. 3\. Cross-Chain Oracles[](https://docs.apechain.com/cross-chain#3-cross-chain-oracles) --------------------------------------------------------------------------------------- Oracles are another area where fast finality is critical. Suppose you want to use a BTC **price feed on ApeChain, but the oracle only exists on Celo**. Today, bridging oracle data across chains is slow and risky, often requiring long delays or trusted intermediaries. With Espresso, as soon as the price update transaction is finalized on Celo, applications on ApeChain can safely react. Espresso guarantees that the oracle update cannot be reverted, enabling fast, secure cross-chain data propagation. This enables: * Cross-chain price feeds * Cross-chain liquidation logic All without waiting for slow finality on a parent chain. 4\. Cross-Chain Gaming[](https://docs.apechain.com/cross-chain#4-cross-chain-gaming) ------------------------------------------------------------------------------------- Fast and secure finality is especially valuable for cross-chain games, where in-game actions often need to happen across multiple blockchains. For example, consider a game where a player performs an action on Chain A that triggers an event on Chain B—like transferring a rare item, updating player stats, or unlocking content. Without fast finality, the game must wait minutes to ensure the first action cannot be reverted, which creates lag and poor user experience. With Espresso, the game can react immediately to cross-chain actions. Player moves, in-game trades, and asset transfers can be finalized in seconds, ensuring seamless gameplay even when multiple chains are involved. This opens up possibilities for real-time cross-chain PvP battles or instant cross-chain marketplace transactions Espresso guarantees that all these actions are secure and irreversible, removing the need for long confirmation delays and improving the overall experience for players. Getting Started =============== Apechain is already integrated with Espresso, so getting started is very easy! If you want to **read from Espresso finality in an existing application**, learn [how to read from the Espresso Network (opens in a new tab)](https://docs.espressosys.com/network/concepts/read-from-network) . If you want to create a cross-chain application from scratch, take a look at the [tutorials that we have available (opens in a new tab)](https://docs.espressosys.com/network/guides/dapp) . --- # Storage - ApeChain Docs Storage Pinata[](https://docs.apechain.com/storage#pinata) --------------------------------------------------- Pinata is the most widely used IPFS provider, offering fast, reliable, enterprise-grade decentralized storage for token metadata, NFTs, and verifiable data or assets of any kind. With an easy setup process, robust API, and developer-friendly SDK, Pinata makes it simple to store and serve media, metadata, and application assets over IPFS without managing your own infrastructure. Comprehensive Pinata Docs can be found at: [https://docs.pinata.cloud/ (opens in a new tab)](https://docs.pinata.cloud/) ### Pinata Storage Fees[](https://docs.apechain.com/storage#pinata-storage-fees) Please visit [https://pinata.cloud/pricing (opens in a new tab)](https://pinata.cloud/pricing) for details. --- # Oracles - ApeChain Docs Oracles Oracles ======= Api3[](https://docs.apechain.com/oracles#api3) ----------------------------------------------- [Api3 (opens in a new tab)](https://api3.org/) delivers first-party oracles that pay you — connecting real-world data directly to smart contracts while reclaiming lost value through Oracle Extractable Value (OEV). Explore the [Api3 Market (opens in a new tab)](https://market.api3.org/apechain) and start earning. Pyth[](https://docs.apechain.com/oracles#pyth) ----------------------------------------------- [Pyth (opens in a new tab)](https://www.pyth.network/) acts as an oracle for ApeChain by providing real-time, reliable data feeds directly to the blockchain. Pyth delivers real-time, reliable data which is vital for Web3 dApps, especially in gaming and DeFi, where smart contracts rely on accurate data. With Pyth, ApeChain gives developers access to high-quality data, boosting the performance of projects built on Apechain. See [here (opens in a new tab)](https://docs.pyth.network/price-feeds/contract-addresses/evm) for more information on the ApeChain Price Feed Contract Addresses | Network | Contract Address | | --- | --- | | Mainnet | `0x2880aB155794e7179c9eE2e38200202908C17B43` | Supra[](https://docs.apechain.com/oracles#supra) ------------------------------------------------- [Supra (opens in a new tab)](https://docs.supra.com/) delivers secure and high-speed data feeds which is crucial for dApps on ApeChain, particularly in areas like DeFi, NFTs, and gaming. By providing accurate and reliable data, Supra ensures that smart contracts on ApeChain operate effectively, enhancing the overall trust and functionality of the ecosystem. --- # Feedback - ApeChain Docs Feedback Feedback[](https://docs.apechain.com/feedback#feedback) -------------------------------------------------------- We're continuously striving to enhance our documentation with feedback from the community. Please share your thoughts using the form below, so we can work together to create the most helpful resources. [Feeback Form →](https://3yc4prw48cq.typeform.com/apechaindocs) --- # Verifying a Smart Contract on Apechain - ApeChain Docs Contracts contract-verification Hardhat Verifying a Smart Contract on Apechain ====================================== Introduction[](https://docs.apechain.com/contracts/contract-verification/hardhat#introduction) ----------------------------------------------------------------------------------------------- Verifying a smart contract on the blockchain is crucial for ensuring its transparency, security, and facilitating interaction for both users and developers. Hardhat is a versatile tool designed for compiling, testing, deploying, and verifying smart contracts. This guide will walk you through the process of verifying your smart contract on the Curtis Network (testnet) using Hardhat. Prerequisites[](https://docs.apechain.com/contracts/contract-verification/hardhat#prerequisites) ------------------------------------------------------------------------------------------------- Before you begin the verification process, make sure you have the following: * **Hardhat Installed**: This is essential for compiling, deploying, and verifying your smart contract. * **Node.js and NPM**: Hardhat operates on Node.js, and NPM (Node Package Manager) is used to install necessary packages. * **Deployed Smart Contract**: Ensure your smart contract is already deployed on the Curtis network. If it isn't, refer to the guide on Deploying a Smart Contract. Step 1: Installing Hardhat Verify Package[](https://docs.apechain.com/contracts/contract-verification/hardhat#step-1-installing-hardhat-verify-package) -------------------------------------------------------------------------------------------------------------------------------------------------------- To enable verification in your Hardhat environment, you need to install the `@nomicfoundation/hardhat-verify` plugin. Run the following command in your project's root directory: npm install --save-dev @nomicfoundation/hardhat-verify Step 2: Configuring Hardhat[](https://docs.apechain.com/contracts/contract-verification/hardhat#step-2-configuring-hardhat) ---------------------------------------------------------------------------------------------------------------------------- After installing the verification plugin, the next step is to configure your Hardhat environment. This involves enabling the necessary plugins and setting up your network details in the `hardhat.config.ts` file. ⚠️ For this example we are adding the private key and api key in the file, **PLEASE** make adjustments and add this sensitive information to a .env file if pushing to a repository Include the following configuration in your `hardhat.config.ts`: import "@nomicfoundation/hardhat-toolbox-viem"; import "@nomicfoundation/hardhat-verify"; import type { HardhatUserConfig } from "hardhat/config"; const config: HardhatUserConfig = { solidity: "0.8.24", networks: { ApeChain: { url: "https://apechain.calderachain.xyz/http", accounts: [\ "YOUR_PRIVATE_KEY",\ ], }, curtis: { url: "https://curtis.rpc.caldera.xyz/http", accounts: [\ "YOUR_PRIVATE_KEY",\ ], } }, sourcify: { enabled: false, apiUrl: "https://sourcify.dev/server", browserUrl: "https://repo.sourcify.dev", }, etherscan: { apiKey: { curtis: "YOUR_ETHERSCAN_API_KEY", }, customChains: [\ {\ network: "ApeChain",\ chainId: 33139,\ urls: {\ apiURL: "https://apechain.calderachain.xyz/http",\ browserURL: "https://apechain.calderachain.xyz/http",\ },\ },\ {\ network: "curtis",\ chainId: 33111,\ urls: {\ apiURL: "https://curtis.explorer.caldera.xyz/api",\ browserURL: "https://curtis.explorer.caldera.xyz/",\ },\ },\ ], }, }; export default config; Step 3: Verifying Your Contract[](https://docs.apechain.com/contracts/contract-verification/hardhat#step-3-verifying-your-contract) ------------------------------------------------------------------------------------------------------------------------------------ Once your project is configured for verification, you can proceed to verify your smart contract on Apechain Mainnet or Testnet. Replace `` with the actual address of your deployed contract. ### For Mainnet[](https://docs.apechain.com/contracts/contract-verification/hardhat#for-mainnet) For verification on the Curtis network, run the following command: npx hardhat verify --network ApeChain < contract-address > This command will communicate with the Apechain network (as specified in your Hardhat configuration) to submit your contract’s source code and metadata for verification. Once successfully verified, your contract’s source code will be publicly accessible on the blockchain, linked to its on-chain address. ### For Testnet[](https://docs.apechain.com/contracts/contract-verification/hardhat#for-testnet) For verification on the Curtis network, run the following command: npx hardhat verify --network curtis < contract-address > This command will communicate with the Curtis network (as specified in your Hardhat configuration) to submit your contract’s source code and metadata for verification. Once successfully verified, your contract’s source code will be publicly accessible on the blockchain, linked to its on-chain address. Conclusion[](https://docs.apechain.com/contracts/contract-verification/hardhat#conclusion) ------------------------------------------------------------------------------------------- Verifying your smart contract not only strengthens your project's transparency and credibility but also greatly enhances the user experience by making interactions and verifications more straightforward. By following the steps in this guide, developers can ensure their contracts are verified and available for public scrutiny, contributing to a more secure and trustworthy ecosystem. --- # Connect - ApeChain Docs Connect Connect with us[](https://docs.apechain.com/Connect#connect-with-us) --------------------------------------------------------------------- Stay in the loop with all things ApeChain! Follow us on our social media channels to get the latest updates, join discussions, and connect with the community. [For all major announcements follow us on X. →](https://x.com/apecoin) [For vibes and daily conversations join us on Telegram. →](https://t.me/apechainofficial) [For technical conversations join our community on Discord. →](https://discord.gg/apecoindao) Apes together, build together! 🍌 --- # Gas Estimator - ApeChain Docs Start Building Gas Estimator Gas Fee Estimator[](https://docs.apechain.com/start-building/Gas-Estimator#gas-fee-estimator) ---------------------------------------------------------------------------------------------- Anyone involved in the blockchain ecosystem has likely used a gas fee estimator at some point. In this guide, we will explore how to build a gas fee estimator using Apechain and Tenderly. ### **Understanding the implementation of the gas fee estimator**[](https://docs.apechain.com/start-building/Gas-Estimator#understanding-the-implementation-of-the-gas-fee-estimator) To build the gas fee estimator, we will make use of some key features of Apechain and Tenderly as listed below: ### **Apechain**[](https://docs.apechain.com/start-building/Gas-Estimator#apechain) * **RPC API for network communication**: We will use Apechain’s **RPC URL** to interact with the blockchain. This will help us with real-time interaction with the Apechain network, enabling us to retrieve accurate gas estimates and submit transactions. ### **Tenderly**[](https://docs.apechain.com/start-building/Gas-Estimator#tenderly) * [**Simulation API** (opens in a new tab)](https://docs.tenderly.co/reference/api#/) : Tenderly simulates transactions within Apechain’s environment, offering accurate gas usage and execution insights. * [**Transaction Simulation** (opens in a new tab)](https://docs.tenderly.co/virtual-testnets/interact/simulate-transactions) : Tenderly simulates the transaction in a controlled environment using the network's specific rules (in this case, Apechain). It mimics how the transaction would behave on-chain, including: * Gas limits * Contract calls * Execution logic **Here’s the simple flow that we will follow to build the gas fee estimator:** 1. **Input transaction details**: The user provides necessary details for the transaction. 2. **Fetch gas price from Apechain**: Get the current gas price from the Apechain network. 3. **Estimate gas using Apechain RPC**: Use Apechain's RPC to estimate the gas required for the transaction. 4. **Simulate transaction on Tenderly**: Simulate the transaction on Tenderly to validate the transaction and predict potential failures. 5. **Return estimated gas fee**: Provide the user with the estimated gas fee for their transaction. Start building[](https://docs.apechain.com/start-building/Gas-Estimator#start-building) ---------------------------------------------------------------------------------------- 1. Sign up on [Tenderly (opens in a new tab)](https://tenderly.co/) . 2. Get the Tenderly account slug and project slug as mentioned in the guide [here. (opens in a new tab)](https://docs.tenderly.co/account/projects/account-project-slug) 3. You’ll need the following libraries to interact with Apechain, Tenderly, and handle gas estimation: npm install ethers axios dotenv 4. Add the Tenderly API key and Apechain URL in a `.env` file as shown below: APECHAIN_RPC_URL=your_apechain_rpc_url_here TENDERLY_API_KEY=your_tenderly_api_key_here 5. Create a new `gasEstimator.js` file and the following code: require('dotenv').config(); const { ethers } = require('ethers'); const axios = require('axios'); // Apechain RPC URL and Tenderly API key from .env const APECHAIN_RPC_URL = process.env.APECHAIN_RPC_URL; const TENDERLY_API_KEY = process.env.TENDERLY_API_KEY; // Set up Apechain provider const provider = new ethers.JsonRpcProvider(APECHAIN_RPC_URL); // Function to estimate gas async function estimateGas(transaction) { try { const gasEstimate = await provider.estimateGas(transaction); console.log(`Estimated Gas: ${gasEstimate.toString()}`); return gasEstimate; } catch (error) { console.error('Error estimating gas:', error); } } // Function to simulate transaction on Tenderly async function simulateTransaction(transaction) { try { const response = await axios.post( `https://api.tenderly.co/api/v1/account/ethereum/simulate`, { transaction, }, { headers: { 'Authorization': `Bearer ${TENDERLY_API_KEY}`, }, } ); console.log('Simulation Result:', response.data); return response.data; } catch (error) { console.error('Error simulating transaction on Tenderly:', error); } } // Example usage: Estimate gas and simulate transaction async function main() { const transaction = { to: '0xRecipientAddressHere', value: ethers.utils.parseEther('0.1'), // 0.1 ETH data: '0x', // Optional: Contract call data }; const gasEstimate = await estimateGas(transaction); await simulateTransaction(transaction); } main(); 6. Run the script to estimate gas and stimulate a transaction: node gasEstimator.js --- # Safes - ApeChain Docs Safes Safes ===== Den[](https://docs.apechain.com/safes#den) ------------------------------------------- [Den (opens in a new tab)](https://docs.onchainden.com/) provides secure, decentralized storage for digital assets on ApeChain, enhancing security for NFTs and in-game items. By integrating Den Safes, ApeChain ensures that assets are protected from breaches while remaining easily accessible for transactions and gameplay. This added security makes ApeChain more appealing to users and developers focused on (but not limited to) Web3 gaming, and NFT dApps. --- # Remix - ApeChain Docs Start Building Remix Remix ===== What is Remix?[](https://docs.apechain.com/start-building/remix#what-is-remix) ------------------------------------------------------------------------------- Remix Project is a robust set of tools that can be used by individuals of any skill level throughout the entire process of developing contracts, and it also serves as an educational platform for learning and experimenting with Ethereum. Getting Started with Remix ( Contract example #1 )[](https://docs.apechain.com/start-building/remix#getting-started-with-remix--contract-example-1-) ----------------------------------------------------------------------------------------------------------------------------------------------------- 1. Visit Remix to get started. 2. Under **Featured Plugins**, select **Solidity**. 3. Navigate to the **File Explorer** and click "**+**" to create a Smart Contract 4. Input your smart contract or use the sample contract below. // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract HelloWorld { string public greeting; // Constructor to set the initial greeting constructor() { greeting = "Hello, ApeChain!"; } // Function to set a new greeting function setGreeting(string memory _greeting) public { greeting = _greeting; } // Function to get the current greeting function getGreeting() public view returns (string memory) { return greeting; } } 5. Navigate to the **Compile** sidebar option and click Compile. ![faucet](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2FRemix_1.08130e64.png&w=3840&q=75) After you compile your contract and you obtain test $Ape from our [Hub Page (opens in a new tab)](https://curtis.hub.caldera.xyz/) you can then select **Environment** on the left-hand side (see below) and switch to the Curtis Network where you can deploy/interact with your contract, this time on testnet as opposed to the VM. ![faucet](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fremix_deploy_share.5ae6be42.png&w=3840&q=75) After you compile you have the ability to interact with the contract on the left side You also have the ability to view the deployment of your contract on the [Curtis Block Explorer (opens in a new tab)](https://curtis.explorer.caldera.xyz/) ![faucet](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fdeployed_contract.ed37a0d6.png&w=3840&q=75) Getting Started with Remix ( Contract example #2 )[](https://docs.apechain.com/start-building/remix#getting-started-with-remix--contract-example-2-) ----------------------------------------------------------------------------------------------------------------------------------------------------- // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract BidBoard { string public message; address public currentAdvertiser; uint public currentAmount; address payable public owner; event MessageUpdated(string newMessage, address indexed newAdvertiser, uint newAmount); constructor() { owner = payable(msg.sender); } modifier onlyOwner() { require(msg.sender == owner, "Only the owner can call this function."); _; } function updateMessage(string calldata newMessage) external payable { require( msg.value > currentAmount, "Must send more Ether than the previous amount." ); message = newMessage; currentAdvertiser = msg.sender; currentAmount = msg.value; owner.transfer(msg.value); emit MessageUpdated(newMessage, msg.sender, msg.value); } function updateOwner(address payable newOwner) external onlyOwner { owner = newOwner; } } In this contract after deployment you have the ability to call on the following updateMessage updateOwnercurrent currentAdvertiser currentAmount message owner ### Post deployment[](https://docs.apechain.com/start-building/remix#post-deployment) After deploying, you’ll see your contract instance appear under "Deployed Contracts." You can now interact with the updateMessage function. ### Interacting with the contract[](https://docs.apechain.com/start-building/remix#interacting-with-the-contract) To send ETH with the updateMessage function: In the _"Value"_ input box above the function list, enter the amount of test ETH you want to send. For example, 2 for 2 ETH. In the "updateMessage" function: Enter a new message in the newMessage input box. Click the "transact" button to send the transaction. This will update the contract’s message and transfer the ETH you specified to the contract's owner. Example: If you enter "Hello, Ape" in the newMessage box and 1 in the Value box, and then click "transact," 2.5 ETH will be sent with the transaction. If this amount is greater than the current highest amount, the contract’s message and advertiser will be updated, and the ETH will be transferred to the owner's address. ### Check the Results[](https://docs.apechain.com/start-building/remix#check-the-results) After the transaction is mined, you can check: * The message variable to see the updated message. * The currentAdvertiser to see the address that sent the ETH. * The currentAmount to see the amount of ETH associated with the current message. --- # APE Builder by Sequence - ApeChain Docs APE Builder by Sequence APE Builder by Sequence ======================= [Ape Builder (opens in a new tab)](https://apechain.sequence.build/landing) by Sequence is a comprehensive NFT toolkit that enables builders to easily create, deploy, and manage NFT collections on ApeChain. Overview[](https://docs.apechain.com/ape-builder-sequence#overview) -------------------------------------------------------------------- Sequence provides a complete suite of tools for NFT development, including: * Smart contract management * Wallet, auth and fiat payments for any user * Custom marketplaces * Gas free interface * Real time analytics and insights * Sequence SDKs for web, mobile, Unity, and Unreal. Launch your first NFT collection with no / low code APE Builder Demo[](https://docs.apechain.com/ape-builder-sequence#demo) ------------------------------------------------------------ Whether you're just getting started or already shipping onchain, these live walkthroughs will guide you through a seamless end-to-end development flow — from deploying collections to launching marketplaces. ### Session 1: Intro to APE Builder[](https://docs.apechain.com/ape-builder-sequence#session-1-intro-to-ape-builder) ### Session 2: Whitelists, royalties, marketplaces etc.[](https://docs.apechain.com/ape-builder-sequence#session-2-whitelists-royalties-marketplaces-etc) --- # Node Providers - ApeChain Docs Node Providers Node Providers ============== Alchemy[](https://docs.apechain.com/node-providers#alchemy) ------------------------------------------------------------ [Alchemy (opens in a new tab)](https://www.alchemy.com/) is providing infrastructure support for ApeChain, offering developer tools like APIs and Rollup technology to enhance performance and scalability. This partnership aims to streamline the development of dApps on ApeChain. Caldera[](https://docs.apechain.com/node-providers#caldera) ------------------------------------------------------------ [Caldera (opens in a new tab)](https://www.caldera.xyz/) supports ApeChain by providing Rollup-as-a-Service infrastructure, including Guardian Nodes for network security and essential tools like a Block Explorer and Bridge Interface. This setup helps decentralize and secure ApeChain while enabling high throughput for a range of dapps. | ApeChain Mainnet | Link | | --- | --- | | RPC http | [https://rpc.apechain.com/http (opens in a new tab)](https://rpc.apechain.com/http) | | RPC (WS) | wss://rpc.apechain.com/ws | | Curtis Testnet | Link | | --- | --- | | RPC http | [https://curtis.rpc.caldera.xyz/http (opens in a new tab)](https://curtis.rpc.caldera.xyz/http) | | RPC (WS) | wss://curtis.rpc.caldera.xyz/ws | Tenderly[](https://docs.apechain.com/node-providers#tenderly) -------------------------------------------------------------- [Tenderly (opens in a new tab)](https://tenderly.co/) supports ApeChain by providing managed RPC nodes, transaction simulation tools, and monitoring services. Developers can deploy nodes, simulate transactions, and test their dApps efficiently on ApeChain using Tenderly's platform, ensuring smooth operation and faster development​. For further exploration on integrations, explore further [here (opens in a new tab)](https://docs.tenderly.co/node/rpc-reference/apechain) . --- # Resources - ApeChain Docs Resources Resources[](https://docs.apechain.com/Resources#resources) ----------------------------------------------------------- These resources will allow you to explore ApeChain in greater depth. Apechain Workshop Video[](https://docs.apechain.com/Resources#apechain-workshop-video) --------------------------------------------------------------------------------------- Links[](https://docs.apechain.com/Resources#links) --------------------------------------------------- * [Alchemy (opens in a new tab)](https://www.alchemy.com/) * [Allium (opens in a new tab)](https://www.allium.so/%5D) * [Arbitrum (opens in a new tab)](https://arbitrum.io/) * [Blockscout (opens in a new tab)](https://www.blockscout.com/) * [Caldera (opens in a new tab)](https://www.caldera.xyz/) * [Den (opens in a new tab)](https://docs.onchainden.com/) * [Etherscan (opens in a new tab)](https://etherscan.io/) * [Foundry (opens in a new tab)](https://book.getfoundry.sh/) * [Hardhat (opens in a new tab)](https://hardhat.org/) * [Metamask (opens in a new tab)](https://metamask.io/) * [Pyth (opens in a new tab)](https://www.pyth.network/) * [Scaffold-ETH-2-Ape (opens in a new tab)](https://github.com/ape-foundation/scaffold-eth-2_ape) * [Supra (opens in a new tab)](https://docs.supra.com/) * [Tenderly (opens in a new tab)](https://tenderly.co/) Articles[](https://docs.apechain.com/Resources#articles) --------------------------------------------------------- * [A gentle introduction: Orbit chains (opens in a new tab)](https://docs.arbitrum.io/launch-orbit-chain/orbit-gentle-introduction) * [How Arbitrum Works: Why Nitro (opens in a new tab)](https://docs.arbitrum.io/how-arbitrum-works/why-nitro) * [How Arbitrum Works: The Sequencer and Censorship Resistance (opens in a new tab)](https://docs.arbitrum.io/how-arbitrum-works/sequencer) * [The Bored Ape Gazette, Setting up a node (opens in a new tab)](https://www.theboredapegazette.com/post/apecoin-dao-contributors-can-set-up-their-own-apechain-nodes-in-just-five-easy-steps-find-out-more) --- # User Onboarding - ApeChain Docs Onboarding User Onboarding =============== Glyph[](https://docs.apechain.com/onboarding#glyph) ---------------------------------------------------- Glyph is designed to streamline the web3 user experience and onboarding within apps, catering two key audiences: End Users and Builders/Developers (third party apps). At its core, Glyph functions as an onboarding solution, acting as the central hub for account management, crypto wallet integration, fiat onramping, gas sponsorship (coming soon), and onchain transactions. By utilizing external services and developing a developer-centric widget, this solution ensures we are creating a secure, efficient, and scalable product. For everyday users, Glyph makes interactions with crypto and blockchain apps easy. | ![Glyph Home](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fglyph-home.7e3b7cf2.png&w=1920&q=75) | ![Glyph Success](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fglyph-success.d9beb61d.png&w=1920&q=75) | | --- | --- | #### For Users[](https://docs.apechain.com/onboarding#for-users) It enables easy onboarding, transactions, and account management without complexity. #### For Developers[](https://docs.apechain.com/onboarding#for-developers) It offers a plug-and-play widget that ensures seamless integration into apps, driving adoption on ApeChain. **Learn more at [Glyph Docs (opens in a new tab)](https://docs.useglyph.io/overview/) or try out the demo: [Glyph Demo (opens in a new tab)](https://demo.useglyph.io/native-integration/) ** ⚠️ React 19 or Next.js 15 is not supported yet. #### Using Glyph with thirdweb[](https://docs.apechain.com/onboarding#using-glyph-with-thirdweb) Glyph is powered by Privy. That means thirdweb devs can use Glyph as the wallet provider just as they would use Privy. Here's the [walkthrough (opens in a new tab)](https://solutions.thirdweb.com/products/how-to-use-thirdweb-with-privy) Sequence[](https://docs.apechain.com/onboarding#sequence) ---------------------------------------------------------- The [Embedded Wallet (opens in a new tab)](https://docs.sequence.xyz/sdk/headless-wallet/quickstart) is designed for a traditional gaming experience. The advantages are: * Authenticate users with common social providers or email. * Support for Unity, Unreal, Web, and Mobile. * Optional pop-ups, modals, and transaction signing for a seamless UX. * Fully non-custodial, smart contract wallet. * Out of the box login with [Web SDK (opens in a new tab)](https://docs.sequence.xyz/sdk/web/overview) or build your own flow. On the other hand, the [Ecosystem Wallet (opens in a new tab)](https://docs.sequence.xyz/solutions/wallets/ecosystem/overview) caters to apps who want to build an entire ecosystem and connect their users to third-party applications such as external marketplaces or DEX's. Our [Web SDK (opens in a new tab)](https://docs.sequence.xyz/sdk/web/overview) library is a customizable UI written in Typescript, tailored for a browser experience. This is great when you want to support users with existing wallets like Metamask, have an out-of-the-box experience, as well as millions of potential new users who prefer the convenience of social login. Lastly, we provide [Wallet Linking (opens in a new tab)](https://docs.sequence.xyz/sdk/web/getting-started) for your ecosystem which enables the ability for a developer to create a verifiable association between two wallets from a single user. Generally, this is a link between an embedded wallet for a game or application and an external wallet, such as Metamask so you can easily query all wallets associated with a single user - across games, ecosystems, and blockchains. Reown (prev. known as WalletConnect)[](https://docs.apechain.com/onboarding#reown-prev-known-as-walletconnect) --------------------------------------------------------------------------------------------------------------- **[Reown (opens in a new tab)](https://reown.com/?utm_source=apechain&utm_medium=docs&utm_campaign=backlinks) ** gives developers the tools to build user experiences that make digital ownership effortless, intuitive, and secure. Reown has two major product offerings, they are, **AppKit** and **WalletKit**. ### AppKit[](https://docs.apechain.com/onboarding#appkit) AppKit is a powerful, free, and fully open-source SDK for developers looking to integrate wallet connections and other Web3 functionalities into their apps on any EVM and non-EVM chain. In just a few simple steps, you can provide your users with seamless wallet access, one-click authentication, social logins, and notifications—streamlining their experience while enabling advanced features like on-ramp functionality, in-app token swaps and smart accounts. ### WalletKit[](https://docs.apechain.com/onboarding#walletkit) WalletKit is a robust, open-source SDK designed to empower seamless wallet connections and interactions across any blockchain. With WalletKit, you can offer your users a simple and secure way to connect with thousands of apps, enabling features like one-click authentication, secure transaction signing, and streamlined wallet address verification. Its chain-agnostic design ensures effortless multi-chain support, eliminating the need for complex integrations while delivering unmatched connectivity and security. To summarize, **AppKit** is for **Web3 applications** and **WalletKit** is for **Web3 wallets**. You will be able to use Reown AppKit to power end-to-end wallet interactions on your Web3 app deployed on ApeChain. Some links to learn more about Reown: * [Website (opens in a new tab)](https://reown.com/?utm_source=apechain&utm_medium=docs&utm_campaign=backlinks) * [Blog (opens in a new tab)](https://reown.com/blog?utm_source=apechain&utm_medium=docs&utm_campaign=backlinks) * [Docs (opens in a new tab)](https://docs.reown.com/?utm_source=apechain&utm_medium=docs&utm_campaign=backlinks) * [Start building with Appkit (opens in a new tab)](https://reown.com/blog/how-to-get-started-with-reown-appkit-on-apechain) --- # Buildkit - ApeChain Docs Start Building Buildkit Buidl, Quickly[](https://docs.apechain.com/start-building/Buildkit#buidl-quickly) ---------------------------------------------------------------------------------- We're excited to announce that we're developing a comprehensive template for developers to leverage the popular starter kit [Scaffold-ETH (opens in a new tab)](https://scaffoldeth.io/) . This BuildKit helps eliminate the need for enviromental setup and configuration and ebales developers to get started building on Apechain in matter of minutes. * packages * hardhat * contracts * BidBoard.sol // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; contract BidBoard { string public message; address public currentAdvertiser; uint public currentAmount; address payable public owner; event MessageUpdated( string newMessage, address indexed newAdvertiser, uint newAmount ); constructor() { owner = payable(msg.sender); message = "Welcome to Apechain"; } modifier onlyOwner() { require(msg.sender == owner, "Only the owner can call this function."); _; } function updateMessage(string calldata newMessage) external payable { require( msg.value > currentAmount, "Must send more Ether than the previous amount." ); message = newMessage; currentAdvertiser = msg.sender; currentAmount = msg.value; owner.transfer(msg.value); emit MessageUpdated(newMessage, msg.sender, msg.value); } function updateOwner(address payable newOwner) external onlyOwner { owner = newOwner; } } You might need to make adjustment to the hardhat.config.ts file apeCurtis: { url: `https://curtis.rpc.caldera.xyz/http/${providerApiKey}`, accounts: [deployerPrivateKey], }, ![index](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Findex_os_ape.5d3ca15d.png&w=3840&q=75) Here is a [Link to the current version (opens in a new tab)](https://github.com/ape-foundation/scaffold-eth-2_ape) of the buildkit, we welcome all contributions towards this effort to ensure developers can start building as quickly as possible. Step-by-Step Setup[](https://docs.apechain.com/start-building/Buildkit#step-by-step-setup) ------------------------------------------------------------------------------------------- ### 1\. Clone the Repository[](https://docs.apechain.com/start-building/Buildkit#1-clone-the-repository) Start by cloning the BuildKit repository: git clone https://github.com/ape-foundation/scaffold-eth-2_ape ### 2\. Install Dependencies[](https://docs.apechain.com/start-building/Buildkit#2-install-dependencies) To get started, you need to clone the repository and then follow the steps below: yarn install [](https://docs.apechain.com/start-building/Buildkit#-1) --------------------------------------------------------- ### 3\. Navigate to NextJS folder[](https://docs.apechain.com/start-building/Buildkit#3-navigate-to-nextjs-folder) While making adjustments you may need to add your private key to the .env file cd packages/nextjs [](https://docs.apechain.com/start-building/Buildkit#-2) --------------------------------------------------------- ### 4\. Run command[](https://docs.apechain.com/start-building/Buildkit#4-run-command) Run the following command on your terminal curl -sSL -o .npmrc https://raw.githubusercontent.com/yuga-labs/ape-portal-public/2bd5d6c85cbb8dfc276c054ddeb0f55a1df459aa/.npmrc [](https://docs.apechain.com/start-building/Buildkit#-3) --------------------------------------------------------- ### 5\. Add Github token[](https://docs.apechain.com/start-building/Buildkit#5-add-github-token) Add github token to youe shell: export GITHUB_TOKEN= [](https://docs.apechain.com/start-building/Buildkit#-4) --------------------------------------------------------- ### 6\. Install ApePortal[](https://docs.apechain.com/start-building/Buildkit#6-install-apeportal) Install ApePortal pacakge: pnpm i @yuga-labs/ape-portal-public [](https://docs.apechain.com/start-building/Buildkit#-5) --------------------------------------------------------- ###  Navigate back to root folder[](https://docs.apechain.com/start-building/Buildkit#navigate-back-to-root-folder) cd ../.. [](https://docs.apechain.com/start-building/Buildkit#-6) --------------------------------------------------------- ### Run local Chain, Deploy and Start[](https://docs.apechain.com/start-building/Buildkit#run-local-chain-deploy-and-start) Run a local network in the first terminal: yarn chain This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in hardhat.config.ts. On a second terminal, deploy the test contract: yarn deploy yarn start Visit your app on: `http://localhost:3000`. You can interact with your smart contract using the `Debug Contracts` page. You can tweak the app config in `packages/nextjs/scaffold.config.ts`. **What's next**: * Edit your smart contract `YourContract.sol` in `packages/hardhat/contracts` * Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing (opens in a new tab)](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts (opens in a new tab)](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation. * Edit your deployment scripts in `packages/hardhat/deploy` * Edit your smart contract test in: `packages/hardhat/test`. To run test use `yarn hardhat:test` As a user, you'll notice locally you can connect immediately to the Curtis network which will display your holdings with your connected wallet and the block explorer auto-directs you to the Curtis block explorer. You can update the message and set a value behind the message. As a user, you are bidding to update the message (string) so, to update the message you need to ensure you are paying more than the previous update, otherwise, it will fail to update the state. 🍌 This is meant to get you developing faster, you will need to tailor the code for your project. --- # NFT Shadows - ApeChain Docs Start Building NFT Shadows Building with NFT Shadows[](https://docs.apechain.com/start-building/NFT-Shadows#building-with-nft-shadows) ------------------------------------------------------------------------------------------------------------ NFT Shadows enable cross-chain NFT ownership through a novel mechanism that replicates ownership states across chains. This allows developers to build applications that interact with NFT ownership on any supported chain, whether it's the NFT's native chain or a shadow chain. Shadow NFTs maintain ownership consistency across chains through the Beacon contract's cross-chain messaging system. ### Core Components[](https://docs.apechain.com/start-building/NFT-Shadows#core-components) * contracts * Beacon.sol * ShadowNFT.sol * IShadowCallbackReceiver.sol #### The Beacon[](https://docs.apechain.com/start-building/NFT-Shadows#the-beacon) The Beacon contract coordinates cross-chain messaging and ownership verification. It: * Manages LayerZero messaging configuration * Handles NFT locking/unlocking on native chains * Coordinates ownership reads across chains * Maintains shadow-to-base collection mappings #### Shadow NFTs[](https://docs.apechain.com/start-building/NFT-Shadows#shadow-nfts) Shadow NFTs are ERC721-compatible tokens that mirror ownership from their native chain. They have two states: * **Locked**: Can only be transferred by the Beacon contract, follows canonical ownership * **Unlocked**: Behaves like a standard ERC721, can be transferred freely ### Integration Patterns[](https://docs.apechain.com/start-building/NFT-Shadows#integration-patterns) #### Native Chain Integration[](https://docs.apechain.com/start-building/NFT-Shadows#native-chain-integration) When building on the native chain where the original NFTs exist, you can leverage the delegation system to enable cross-chain ownership control. Here's an example rental system: contract NFTRental { IExclusiveDelegateResolver public resolver; IDelegateRegistry public registry; mapping(uint256 => uint40) public tokenIdToExpiration; function rentOut( address nft, uint256 tokenId, uint40 duration ) external { // Verify contract owns the NFT require(IERC721(nft).ownerOf(tokenId) == address(this), "Contract does not own NFT"); // Verify NFT is not already rented out require(tokenIdToExpiration[tokenId] < block.timestamp, "NFT is already rented out"); // Calculate expiration timestamp uint40 expiration = uint40(block.timestamp) + duration; // Generate delegation rights with expiration bytes32 rights = resolver.generateRightsWithExpiration( bytes24(0), // rights identifier expiration ); // Issue delegation to renter registry.delegateERC721( renter, nft, tokenId, rights, true // enable delegation ); tokenIdToExpiration[tokenId] = expiration; } } #### Shadow Chain Integration[](https://docs.apechain.com/start-building/NFT-Shadows#shadow-chain-integration) When building on chains where Shadow NFTs exist, you have two approaches for ownership verification: ##### 1\. Optimistic Ownership Checks[](https://docs.apechain.com/start-building/NFT-Shadows#1-optimistic-ownership-checks) Best for non-critical operations where slight ownership lag is acceptable: contract OptimisticIntegration { INFTShadow public shadowNft; function doSomethingWithNFT(uint256 tokenId) external { // Simple ownership check require(shadowNft.ownerOf(tokenId) == msg.sender, "Not owner"); // Proceed with operation... } } ⚠️ Optimistic checks should only be used for low-risk operations as there may be a slight delay in ownership updates across chains. ##### 2\. Verified Ownership with Callbacks[](https://docs.apechain.com/start-building/NFT-Shadows#2-verified-ownership-with-callbacks) For operations requiring guaranteed up-to-date ownership: contract VerifiedIntegration is IShadowCallbackReceiver { INFTShadow public shadowNft; IBeacon public beacon; struct PendingOperation { address caller; uint256 tokenId; } mapping(bytes32 => PendingOperation) public pendingOperations; function doSomethingWithVerifiedOwnership(uint256 tokenId) external payable { uint256[] memory tokenIds = new uint256[](1); tokenIds[0] = tokenId; uint32[] memory eids = new uint32[](1); eids[0] = sourceChainEid; uint256 fee = beacon.quoteRead( address(shadowNft), tokenIds, eids, 60000 // callback gas limit ); require(msg.value >= fee, "Insufficient fee"); bytes32 guid = shadowNft.readWithCallback{value: fee}( tokenIds, eids, 60000 ); pendingOperations[guid] = PendingOperation({ caller: msg.sender, tokenId: tokenId }); } } ### Error Handling and Edge Cases[](https://docs.apechain.com/start-building/NFT-Shadows#error-handling-and-edge-cases) #### Read Request Failures[](https://docs.apechain.com/start-building/NFT-Shadows#read-request-failures) * If a read request fails, the callback will not be executed * Operations should be designed to be idempotent * Consider allowing operations to be cancelled after a timeout period #### Ownership Transitions[](https://docs.apechain.com/start-building/NFT-Shadows#ownership-transitions) * Shadow ownership can change between read request and callback * Implement appropriate checks in callback handler * Consider if operation should still proceed if ownership changed #### Gas Considerations[](https://docs.apechain.com/start-building/NFT-Shadows#gas-considerations) `readWithCallback` accepts a `callbackGasLimit` parameter that is used to estimate the gas limit for the callback. This is added as a buffer to the predicted lzReceive gas cost. // Calculate gas limit based on operation complexity uint128 baseGas = 60000; // example base gas limit that callback requires to execute uint128 perNftGas = 15000; // example gas for operations per NFT uint128 callbackGasLimit = baseGas + (perNftGas * tokenIds.length); ### Best Practices[](https://docs.apechain.com/start-building/NFT-Shadows#best-practices) 1. **Ownership Verification** * Use optimistic checks for low-risk operations * Implement callbacks for high-value transactions * Consider implementing timeout mechanisms 2. **Gas Management** * Scale callback gas limits with operation complexity * Include buffer for unexpected gas costs 3. **State Management** * Store minimal data in pending operation mappings * Clean up state after callback execution * Implement operation timeout cleanup Contracts:[](https://docs.apechain.com/start-building/NFT-Shadows#contracts) ----------------------------------------------------------------------------- | Contract | Network | Address | | --- | --- | --- | | BAYC Shadow | ApeChain | [0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d (opens in a new tab)](https://apescan.io/token/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d) | | MAYC Shadow | ApeChain | [0x60e4d786628fea6478f785a6d7e704777c86a7c6 (opens in a new tab)](https://apescan.io/address/0x60e4d786628fea6478f785a6d7e704777c86a7c6) | | BAKC Shadow | ApeChain | [0xba30e5f9bb24caa003e9f2f0497ad287fdf95623 (opens in a new tab)](https://apescan.io/address/0xba30e5f9bb24caa003e9f2f0497ad287fdf95623) | --- # Architecture - ApeChain Docs Architecture ApeChain Architecture[](https://docs.apechain.com/architecture#apechain-architecture) -------------------------------------------------------------------------------------- ### Orbit chains offer:[](https://docs.apechain.com/architecture#orbit-chains-offer) * **Full EVM equivalence** * **Anytrust Data Availability for ultra-low-cost transactions** * **Dedicated throughput and increased gas price reliability** * **Independence and upgradability** By settling on Arbitrum One, ApeChain is able to leverage Arbitrum's security and infrastructure, while still maintaining the benefits of being an independent chain. As Arbitrum One is itself settling on and secured by Ethereum, ApeChain is able to benefit from Ethereum's security and liquidity. ![orbit](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2FApeFlow.753ce3a0.png&w=3840&q=75) ApeChain is an Optimistic L3[](https://docs.apechain.com/architecture#apechain-is-an-optimistic-l3) ---------------------------------------------------------------------------------------------------- As with all Orbit chains, ApeChain is an Optimistic L3. Blockchain rollups were initially a scaling solution designed to increase transaction throughput and reduce fees on Layer 1 networks like Ethereum -- now, rollups as a category encompasses a large, diverse set of chains. They work by bundling or "rolling up" multiple transactions into a single batch, which is then processed and verified on the main chain. This approach moves most of the computational work off-chain while still maintaining the security guarantees of the underlying blockchain. ApeChain's proof system works Optimistically, which means that it assumes that all transactions are valid until proven otherwise. This allows for fast transaction confirmation times, and game theoretic security. Other optimistic chains include Arbitrum, Optimism, and Base. ApeChain currently boasts[](https://docs.apechain.com/architecture#apechain-currently-boasts) ---------------------------------------------------------------------------------------------- * 0.25s **minimum** blocktime * $APE as a native token * Native Bridge for [Mainnet (opens in a new tab)](https://apechain.com/portal#bridge) and [Testnet (opens in a new tab)](https://curtis.bridge.caldera.xyz/) * Functional [Native Yield](https://docs.apechain.com/native/Overview) * Fast Withdrawals Security Council[](https://docs.apechain.com/architecture#security-council) ---------------------------------------------------------------------------- ApeChain utilizes a Security Council to address critical risks associated with the ApeChain protocol and its ecosystem. The ApeCoin DAO will soon administer Security Council elections, so that the APE community can democratically determine who will be responsible for being vigilant about the security and integrity of the ApeChain protocol. While this process is being established by the ApeCoin DAO, an interim Security Council has been established, currently consisting of a small group of Ape Foundation and infrastructure partner signers. Further Reading[](https://docs.apechain.com/architecture#further-reading) -------------------------------------------------------------------------- [A gentle introduction: Orbit chains (opens in a new tab)](https://docs.arbitrum.io/launch-orbit-chain/orbit-gentle-introduction) [How Arbitrum Works: Why Nitro (opens in a new tab)](https://docs.arbitrum.io/how-arbitrum-works/why-nitro) [How Arbitrum Works: The Sequencer and Censorship Resistance (opens in a new tab)](https://docs.arbitrum.io/how-arbitrum-works/sequencer) --- # Foundry - ApeChain Docs Start Here Foundry Foundry ======= What is Foundry?[](https://docs.apechain.com/advanced/foundry#what-is-foundry) ------------------------------------------------------------------------------- Foundry is a Rust-based toolset for Ethereum development that helps developers manage dependencies, compile projects, run tests, deploy contracts, and interact with blockchains via the command line interface. 💡 This tutorial will walk you through the process of deploying and interacting with a smart contract on ApeChain's Curtis Testnet using Foundry. ### **Prerequisites**[](https://docs.apechain.com/advanced/foundry#prerequisites) * **Adding Apechain Testnet to MetaMask:** * You can find and add chain details [here (opens in a new tab)](https://curtis.hub.caldera.xyz/) to your MetaMask. * **Obtaining Test ETH (Sepolia) and Bridging to Apechain Testnet:** * Visit [https://curtis.hub.caldera.xyz/ (opens in a new tab)](https://curtis.hub.caldera.xyz/) * Click on “Faucet” * Enter your wallet address * Click on "Request” * **Required Installations:** * Node, NPM * Basic knowledge of React.js and Solidity Get Started with Foundry[](https://docs.apechain.com/advanced/foundry#get-started-with-foundry) ------------------------------------------------------------------------------------------------ Installing Foundry is simple. For MacOS and Linux, run the following command: ### **Linux or MacOS:**[](https://docs.apechain.com/advanced/foundry#linux-or-macos) curl -L https://foundry.paradigm.xyz | bash foundryup ### Windows:[](https://docs.apechain.com/advanced/foundry#windows) curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil --bins --locked **Create a Project**[](https://docs.apechain.com/advanced/foundry#create-a-project) ------------------------------------------------------------------------------------ Once we have Foundry installed, the next step is to initialize a new project. forge init foundry Navigate to the source folder and Create a Smart Contract File: cd src touch MyToken.sol **Write Your Smart Contract**[](https://docs.apechain.com/advanced/foundry#write-your-smart-contract) ------------------------------------------------------------------------------------------------------ // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract HelloApe { string public greeting = "Hello, Ape!"; function greet() public view returns (string memory) { return greeting; } } **Compile Contract**[](https://docs.apechain.com/advanced/foundry#compile-contract) ------------------------------------------------------------------------------------ After writing our smart contract the next thing is to compile it and to do that we are going to copy and paste the command below into our terminal, please make sure you are in the projects root directory. forge build If it compiles with no errors, the contract is correct, and we are ready to deploy it to Apechain. **Smart Contract Deployment on Apechain**[](https://docs.apechain.com/advanced/foundry#smart-contract-deployment-on-apechain) ------------------------------------------------------------------------------------------------------------------------------ When deploying smart contract to any chain, you need to pay deployment gas fee using the chains native token and it is no different for Apechain, before deploying to Apechain you need to make sure that you've acquired $APE testnet tokens. You can deploy on Apechain by running forge create, followed by the RPC URL, your wallet's private key, and the source of your smart contract. forge create --rpc-url "https://curtis.rpc.caldera.xyz/http" --private-key `your-private-key` src/FileName.sol:ContractName You should see a response similar to the one below: ![Alt Text](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ffoundry-terminal.560ab73a.png&w=3840&q=75) Congrats 🎉 🎊 you just deployed your smart contract to Apechain! Copy out the smart contract address “Deployed to” we’re going to be needing it on our React project. **Verify smart contract deployment**[](https://docs.apechain.com/advanced/foundry#verify-smart-contract-deployment) -------------------------------------------------------------------------------------------------------------------- Visit [Apechain’s explorer (opens in a new tab)](https://curtis.explorer.caldera.xyz/) , copy and paste your contract address into the search bar and you should be able to see your smart contract and all related transactions. Interacting with the Smart Contract[](https://docs.apechain.com/advanced/foundry#interacting-with-the-smart-contract) ---------------------------------------------------------------------------------------------------------------------- We are now done with the creation and deployment of our smart contract. Now it's time to build a simple ReactJS app. npx create-react-app my-dapp **Install ethers.js**[](https://docs.apechain.com/advanced/foundry#install-ethersjs) ------------------------------------------------------------------------------------- Ethers.js is a library that facilitates interaction between web applications and the blockchain. On your terminal, navigate to the folder of the React Project you just created and run the command below. npm install ethers **Declare Contract Address and ABI**[](https://docs.apechain.com/advanced/foundry#declare-contract-address-and-abi) -------------------------------------------------------------------------------------------------------------------- The ABI (Application Binary Interface) is a crucial component in Ethereum smart contracts, serving as a method selector. It defines the specific functions and data structures that can be invoked on a smart contract, enabling interaction between the contract and external applications. You can get your smart contract’s ABI once your contract builds successfully, to locate it, navigate to you out folder, you’ll see a folder with the same name as your solidity file, expand the folder and you’ll see a JSON file copy the JSON file and paste into the root folder of your ReactJS project. **Code the UI**[](https://docs.apechain.com/advanced/foundry#code-the-ui) -------------------------------------------------------------------------- Now that we have our ABI file and ethers.js installed, the next step is to build our UI. but how you choose to build your UI is entirely up to you and the purpose of your app but for this guide, we are just going to have a UI with a simple button and text to display the message returned by our smart contract. import React, { useEffect, useState } from "react"; import { ethers } from "ethers"; import ABI from "./HelloWorld.json"; function App() { const [provider, setProvider] = useState(null); const [message, setMessage] = useState(null); const contractAddress = "YOUR-DEPLOYED-SMART-CONTRACT-ADDRESS"; useEffect(() => { if (typeof window !== "undefined") { if (window.ethereum) { const initializeProvider = async () => { if (window.ethereum) { await window.ethereum.request({ method: "eth_requestAccounts" }); const provider = new ethers.providers.Web3Provider(window.ethereum); setProvider(provider); } }; initializeProvider(); } else { console.error("Please install MetaMask!"); } } }, []); const greet = async () => { const contract = new ethers.Contract(contractAddress, ABI.abi, provider); const result = await contract.greet(); setMessage(result); console.log(result); }; return (

Apechain

{message}

); } export default App; In the above code we imported useEffect, useState, etherjs and our ABI JSON file, next we set our provider and message state and our contract address, after that, we initialized our provider inside of a useEffect so that it gets initialized as soon as the page loads, below that we have our greet function which creates a new instance of our deployed contract using the contractAddress, ABI and the provider we initialized earlier, after which we then hit the greet function we wrote in our smart contract and then set it to our message state so we can render it on the screen. **Run the Project**[](https://docs.apechain.com/advanced/foundry#run-the-project) ---------------------------------------------------------------------------------- npm start **Conclusion**[](https://docs.apechain.com/advanced/foundry#conclusion) ------------------------------------------------------------------------ This tutorial covered deploying and interacting with a smart contract on Apechain using Foundry. We installed Foundry, created a project, wrote and compiled a smart contract, and deployed it on Apechain. We then created a React app to interact with the contract using ethers.js. --- # Verified Random Number Generator (vRNG) - ApeChain Docs Verified Random Number Generator (vRNG) Verified Random Number Generator (vRNG) ======================================= Proof of Play vRNG[](https://docs.apechain.com/vrng#proof-of-play-vrng) ------------------------------------------------------------------------ * Fast, secure, and scalable onchain random number generation. * Because speed matters, we're heavily focused on serving random numbers as fast as possible to reduce latency in applications. Registration[](https://docs.apechain.com/vrng#registration) ------------------------------------------------------------ During early access, all users of the Verified Random Number Generator system **must be** manually registered. ⚠️ In order to use it your contract address **must be** approved, otherwise any requests will revert. ### Supported Networks[](https://docs.apechain.com/vrng#supported-networks) | **Network** | **Address** | **API Url** | | --- | --- | --- | | Apechain Mainnet | [0x9eC728Fce50c77e0BeF7d34F1ab28a46409b7aF1 (opens in a new tab)](https://apescan.io/address/0x9eC728Fce50c77e0BeF7d34F1ab28a46409b7aF1#readProxyContract) | [https://vrf.proofofplay.com/v1 (opens in a new tab)](https://vrf.proofofplay.com/v1) | | Ape Curtis Testnet | [0xd14D984603b0b7Ade91bE52f3Fc4A917Dfa77bcD (opens in a new tab)](https://curtis.apescan.io/address/0xd14D984603b0b7Ade91bE52f3Fc4A917Dfa77bcD#readProxyContract) | [https://staging.vrf.proofofplay.com/v1 (opens in a new tab)](https://staging.vrf.proofofplay.com/v1) | ### Usage: Requesting a Random Number[](https://docs.apechain.com/vrng#usage-requesting-a-random-number) The following interface provides a method for requesting random numbers. Your contract can call the VRFSystem deployed on each chain. You can optionally provide a traceId, which will be annotated to each event (Useful if you have one transaction that does many steps, users can trace their transactions on chain). This is **not required** and can be left as 0. // SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.26; uint256 constant ID = uint256(keccak256('com.proofofplay.vrfsystem.v1')); interface IVRFSystem { /** * Starts a VRF random number request * * @param traceId Optional Id to use when tracing the request * @return requestId for the random number, will be passed to the callback contract */ function requestRandomNumberWithTraceId(uint256 traceId) external returns (uint256); } ### Random Number Callbacks[](https://docs.apechain.com/vrng#random-number-callbacks) Every random number requested is delivered as soon as the first available number from drand is available to be delievered. This can take as long as 3 seconds. ⚠️ Your call will be delivered the first number **after** your first requestForRandomNumber has been requested. This ensures the number **can not** be known before the user has requested the random number. // SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.26; interface IVRFSystemCallback { /** * Callback for when a Random Number is delivered * * @param requestId Id of the request * @param randomNumber Random number that was generated by the Verified Random Number Generator Tool */ function randomNumberCallback(uint256 requestId, uint256 randomNumber) external; } ### What if I want to have different numbers in the same 3 second window?[](https://docs.apechain.com/vrng#what-if-i-want-to-have-different-numbers-in-the-same-3-second-window) By default, we deliver the same number to all requests inside the same 3 second window that drand provides. This is great to be able to verify, but if you would like to have users all have different numbers over this time period, we recommend you add a source of entropy. Here's a couple of examples of having unique random numbers per transaction. // Add the requestId (Most Gas Efficient) uint256 newRandomNumber = requestId + randomNumber; // Hash with requestId uint256 newRandomNumber = uint256(keccak256(abi.encodePacked(requestId, randomNumber) // More expensive, but more normalized, hash based on requestId in last 256 block hashes uint256 newRandomNumber = uint256(keccak256(abi.encodePacked(blockhash(block.number - (requestId % 256)), randomNumber) Note: These are not guaranteed to be normalized, but will retain the randomness properties of the above. We recommend adjusting to your liking to achieve more or less normalized (for instance, adding sequenceId to the randomNumber would be very skewed, whereas using a blockhash would be very normalized). If you would like to have different numbers on the same block, recommend re-hashing the same number multiple times in the same transaction functionThatUsesNumber(randomNumber); randomNumber = uint256(keccak256(randomNumber)); functionThatUsesNumber(randomNumber); ### What if I want to have different numbers in the same transaction?[](https://docs.apechain.com/vrng#what-if-i-want-to-have-different-numbers-in-the-same-transaction) By default, we will give you only one number per transaction. We encourage developers to use this number to dervive other numbers from this to create new numbers. //Example 1: Keccak dervive uint256 randomNumber = 12398012938091283113928; uint256 randomNumber2 = keccak256(randomNumber); uint256 randomNumber3 = keccak256(randomNumber2); //Example 2: Split the number and use both sides uint256 randomNumber = 234345234523452345; uint256 randomNumber2 = randomNumber >> 128; // Take upper 128 bits uint256 randomNumber3 = randomNumber & ((1 << 128) - 1); // Take lower 128 bits ### Blockchain Events[](https://docs.apechain.com/vrng#blockchain-events) The contract will emit the following events. /// @notice Emitted when a random number request is initiated /// @param requestId The unique identifier for the random number request /// @param callbackAddress The address the random number is requested to /// @param traceId The trace ID used to track the request across transactions (0 if no trace ID) event RandomNumberRequested(uint256 indexed requestId, address indexed callbackAddress, uint256 indexed traceId); /// @notice Emitted when a random number is successfully delivered /// @param requestId The unique identifier of the fulfilled request /// @param callbackAddress the adddress was random number is requested to /// @param traceId The trace ID associated with the request /// @param number The round number that was used for the random number /// @param randomNumber The random number that was generated event RandomNumberDelivered(uint256 indexed requestId, address indexed callbackAddress, uint256 indexed traceId, uint256 roundNumber, uint256 randomNumber); You can query these events on RPC level to see if they were delivered or use the block explorer to view a stream of events. ### Verifying the round number / random number with drand[](https://docs.apechain.com/vrng#verifying-the-round-number--random-number-with-drand) If you want to verify the random number, you can check directly with drand for this. We use drand's **quicknet** for this. **For instance, to see the roundNumber 11:** GET [https://api.drand.sh/52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971/public/11 (opens in a new tab)](https://api.drand.sh/52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971/public/11) { "round": 11, "randomness": "ebdcbfe855d10c56db22455fa5a18963c1f62d85f859c35c310273449b49d284", "signature": "163d14081e191a3f5d81e2f580eab591ea608402fda4f6e44b5a0bde11e368070e77d07ad3240726ea33e410c84d4b09ea0a4a0291f6c3c485d8630e1c0edf0a" } We can see here the random number in hex is `ebdcbfe855d10c56db22455fa5a18963c1f62d85f859c35c310273449b49d284` ### Manual Retries with EIP712 signatures[](https://docs.apechain.com/vrng#manual-retries-with-eip712-signatures) 💡 **This feature is in Preview**. Please contact us on slack if you wish to use this. In a very rare instance, you may see random numbers fail to be delivered. In most cases this will be an issue on the contract side. In these situations, you can choose to deliver this number yourself. First you should request the EIP712 signature from our API servers which you can use to deliver the random nummber directly to the contract on the blockchain. **Request:** [Try the API! (opens in a new tab)](https://docs.proofofplay.com/services/vrng/api) GET https://vrf.proofofplay.com/v1/vrf/{chainId}/{txHash} **Response:** { "requestId": Number, "roundNumber": Number, "randomNumber": BigInt, "signature": String // bytes data of signature } With the response you can now call the VRFSystem contract vrf.deliverSignedRandomNumber(requestId, roundNumber, randomNumber, signature); ⚠️ You will be racing the normal relay flow. If you get a tx revert with InvalidRequestId, this means that a relay has already delivered this random number. Random numbers can only be delivered once. ![how-vrng-works](https://docs.apechain.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fhow-vrng-works.00f38673.jpeg&w=3840&q=75) --- # Hardhat - ApeChain Docs Start Here Hardhat Creating Your First DApp Using Apechain and Hardhat[](https://docs.apechain.com/advanced/hardhat#creating-your-first-dapp-using-apechain-and-hardhat) ------------------------------------------------------------------------------------------------------------------------------------------------------ The goal of this project is to deploy a contract and create a basic front-end interface for interacting with it. From there, you have the freedom to expand and enhance the project with your own ideas and creativity! ### What is Hardhat?[](https://docs.apechain.com/advanced/hardhat#what-is-hardhat) Hardhat is a development environment for Ethereum that helps developers manage and automate the common tasks involved in building smart contracts and decentralized applications. It can directly interact with Caldera's Ethereum API, allowing for the deployment of smart contracts into the Caldera network. Additionally, Hardhat is a comprehensive set of tools for creating Ethereum-based software, which includes various components that aid in editing, compiling, debugging, and deploying smart contracts and decentralized applications. All of these components work together to create a complete development environment. In this guide we will see how you can build a token wallet dApp using Hardhat and Apechain. Prerequisites[](https://docs.apechain.com/advanced/hardhat#prerequisites) -------------------------------------------------------------------------- **Basic Knowledge:** - [Solidity (opens in a new tab)](https://docs.soliditylang.org/en/v0.8.26/) For writing smart contracts. - [React (opens in a new tab)](https://react.dev/) For scripting and frontend development. **Development Environment:** - **Node.js** and **npm/yarn**: Installed from [Node.js (opens in a new tab)](https://nodejs.org/) . - **Hardhat**: Development environment for Ethereum. - Install with: npm install --save-dev hardhat * [Metamask (opens in a new tab)](https://metamask.io/) A crypto wallet browser extension also available on mobile. * [Ethers.js (opens in a new tab)](https://docs.ethers.org/v5/) Library to interact with Ethereum. npm install ethers * **OpenZeppelin Contracts**: Secure smart contract library. * Install with: npm install @openzeppelin/contracts Step-by-Step Guide[](https://docs.apechain.com/advanced/hardhat#step-by-step-guide) ------------------------------------------------------------------------------------ ### Step 1: Set Up Hardhat Project[](https://docs.apechain.com/advanced/hardhat#step-1-set-up-hardhat-project) 1. **Initialize a new Hardhat project:** mkdir helloApe cd helloApe npx hardhat also run npm i dotenv We will use an `.env` file to hold our private key and pass it into our `hardhat.config.js` file. Once installed, at the root create a file named `.env` You will be prompted with questions in your terminal. You can simply choose the default options, which will generate a basic code template for you. While you can experiment with this template, for the purpose of this guide, we'll focus on making a few specific changes to some files. Before we move ahead with the guide, here’s an example of how the folder structure would look like: * helloApe * contracts * Lock.sol * ignition * Lock.js * node\_modules * test * Lock.js * .gitignore * hardhat.config.js * package-lock.json * package.json * .env * README.md ### Step 2: Write the HelloApe Contract[](https://docs.apechain.com/advanced/hardhat#step-2-write-the-helloape-contract) Inside your `Lock.sol` file, delete the existing boilerplate code and then copy and paste the code below. This is a simple Solidity file that defines a string ‘greeting’ and a function that returns the string. // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; contract HelloApe { string public greeting = "Hello, Apes!"; function greet() public view returns (string memory) { return greeting; } } ### Step 3: Update your ignition file[](https://docs.apechain.com/advanced/hardhat#step-3-update-your-ignition-file) Open your `Lock.js` file which you can find by navigating to ignition folder and then module folder. This code defines a Hardhat Ignition module called "HelloModule" that deploys the "HelloApe" contract and returns the deployed instance as `hello`. You can just copy this and paste into your file. Also note that you can rename files, just keep it consistant throughout the project. // This setup uses Hardhat Ignition to manage smart contract deployments. // Learn more about it at https://hardhat.org/ignition const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules"); module.exports = buildModule("HelloApe", (m) => { const lock = m.contract("HelloApe"); return { lock }; }); ### Step 4: Configure Hardhat for Apechain[](https://docs.apechain.com/advanced/hardhat#step-4-configure-hardhat-for-apechain) 1. **Modify `hardhat.config.js` to include necessary plugins and configurations:** Notice we are adding `require('dotenv').config();` and `accounts: [process.env.PRIVATE_KEY]` to pass out private key in. require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config(); /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { solidity: "0.8.17", networks: { apechain: { url: "https://curtis.rpc.caldera.xyz/http", accounts: [process.env.PRIVATE_KEY], }, }, }; inside of your `.env` file add the following PRIVATE_KEY=YOUR KEY HERE WITH NO QUOTES 💡 Ensure your `.gitignore` file has `.env` added ### Step 5: Compile and Deploy[](https://docs.apechain.com/advanced/hardhat#step-5-compile-and-deploy) 1. **Compile the contract:** npx hardhat compile 2. **Deploy the contract to Apechain:** npx hardhat ignition deploy ./ignition/modules/Lock.js --network apechain 💡 Keep the deployed contract address, this will be needed for the frontend. ### Step 6: Set Up Frontend with React[](https://docs.apechain.com/advanced/hardhat#step-6-set-up-frontend-with-react) 1. **Initialize a new React project within the same folder:** npx create-react-app frontend cd frontend npm install ethers 2. **Grab your ABI** To connect to the smart contract, you'll need the contract's **ABI**. This can be found in the artifacts folder, which is automatically generated when you deploy your smart contract. To locate it, navigate to the artifacts folder, then to the contract folder. Find the JSON file (in our case, it's named `HelloApe.json`), copy it, and paste it into the `src` folder of your frontend project. * helloApe * artifacts * contracts * HelloApe.json * cache * contracts * ignition * frontend * src * App.js * HelloApe.json * node\_modules * test * .gitignore * hardhat.config.js * package-lock.json * package.json * .env * README.md 3. **Update `App.js`** import { useState } from "react"; import { ethers } from "ethers"; import Contract from "../src/HelloApe.json"; const tokenAddress = "YOUR_CONTRACT_ADDRESS"; function App() { const [userAddress, setUserAddress] = useState(""); const [greeting, setGreeting] = useState(""); async function getGreeting() { if (typeof window.ethereum !== "undefined") { const [account] = await window.ethereum.request({ method: "eth_requestAccounts", }); setUserAddress(account); const provider = new ethers.BrowserProvider(window.ethereum); const contract = new ethers.Contract( tokenAddress, Contract.abi, provider ); const greetingFromContract = await contract.greeting(); setGreeting(greetingFromContract); } } return (

{userAddress}

{greeting}

); } export default App; 4. **Update your CSS** Navigate to your `App.css` file, delete the boilerplate and add the following .App { display: flex; justify-content: center; align-items: center; height: 100vh; text-align: center; } .App-header { display: flex; flex-direction: column; align-items: center; justify-content: center; } h2 { margin: 10px 0; } button { padding: 10px 20px; font-size: 16px; cursor: pointer; margin-top: 20px; } 3. **Run the Frontend** **Start the React app**: **Make sure you are in your frontend directory** and then run the following command npm start Your React application should now be running, and you can interact with the token wallet dApp through your browser! Conclusion[](https://docs.apechain.com/advanced/hardhat#conclusion) -------------------------------------------------------------------- In this guide, you have learned how to build a simple dApp using Hardhat and React, integrated with the Apechain network. By following the step-by-step instructions, you have set up a Hardhat project, written a basic contract, deployed it to Apechain, and created a React frontend to interact with the contract. --- # ApePortal FAQ - ApeChain Docs FAQ Ape Portal ApePortal FAQ ============= #### This FAQ will help you utilize the portal and navigate both Bridge and Swap functionalities.[](https://docs.apechain.com/FAQ/Ape-Portal#this-faq-will-help-you-utilize-the-portal-and-navigate-both-bridge-and-swap-functionalities) ### How do I bridge tokens to ApeChain? ➔ ### Step 1 Connect your wallet to Ape Portal. ### Step 2 Choose the network and token you want to bridge. We recommend bridging APE from Ethereum Mainnet to ApeChain. You'll need ApeChain APE for gas on ApeChain Mainnet. ### Step 3 If you're bridging APE to ApeChain, ensure the originating network is set to Ethereum Mainnet, and select the APE token. Note: Ape Portal also supports cross-chain swaps. This allows you to bridge Ethereum Mainnet ETH directly to ApeChain APE with an additional cross-chain swap fee. You can bridge almost any EVM-compatible token to ApeChain APE. ### Step 4 If needed, approve the token for the bridge transaction. ### Step 5 Sign the transaction to start the bridge process. ### Step 6 Once the transaction is complete, check your wallet or use [ApeScan](https://apescan.io/) to verify your balance on ApeChain. ### What’s the difference between bridging tokens and swapping tokens? ➔ **Bridging tokens** involves transferring tokens from one blockchain to another. For example, if you want to move your tokens from Ethereum to ApeChain, the bridge will lock your tokens on the source chain and mint equivalent tokens on the destination chain. This ensures that the total supply of tokens stays consistent across both networks. Once bridged, you can use the tokens on the destination network. **Swapping tokens** refers to exchanging one token for another on the same blockchain network. This allows users to trade tokens based on current market rates using the Swap functionality within Ape Portal. **Cross-chain swaps** allow you to swap tokens across different blockchain networks. Ape Portal’s Bridge enables users to exchange an EVM-compatible currency for another, even if the tokens are on different networks. This feature is ideal for users looking to perform swaps as part of their cross-chain activity. **In summary:** * **Bridging** moves tokens between different chains. * **Swapping** exchanges tokens within the same chain. * **Cross-chain swaps** allow you to swap EVM-compatible tokens across different networks. ### How do I swap tokens on ApeChain? ➔ ### Step 1 Navigate to the Swap tab in the ApeChain Portal. ### Step 2 Select the network where you'd like to perform the swap. ### Step 3 Choose or search for the tokens you wish to swap. For example, you can swap APE for another token on ApeChain. ### Step 4 Adjust the slippage tolerance if needed (the default is set to 1%). Note: A slippage tolerance of 1% works well for most swaps. Be cautious with higher tolerances to avoid unfavorable trades. ### Step 5 Confirm the swap and sign the transaction in your wallet. ### Step 6 The swapped tokens will appear in your wallet balance once the transaction is complete. ### How do I withdraw tokens from ApeChain? ➔ ### Step 1 Go to the Bridge tab and select ApeChain as the "From" network. Make sure to set the token to APE if you're withdrawing APE. ### Step 2 Choose the destination network and the amount of APE (or other tokens) you want to withdraw. ### Step 3 Sign the transaction to initiate the withdrawal. ### Step 4 Once the required time has passed, confirm the transaction based on the destination network's processing time. ⚠️ Note: Some canonical bridges, such as Arbitrum, have a 7-day withdrawal waiting period for security reasons. A canonical bridge is an official bridge managed by the network itself, ensuring token transfers maintain the same token standard and security. These bridges often have longer waiting periods to enhance security. Please pay attention to any withdrawal warnings in the Portal before signing. If you initiate a transaction with a 7-day withdrawal, it cannot be undone, and you must wait the full 7 days. For a faster option, you can initiate a faster withdrawal (cross-chain swap), which will complete more quickly. ### How long do withdrawals take? ➔ Withdrawals from ApeChain can vary based on the destination network and the bridge route you choose. Fast-bridge withdrawals typically take a few minutes, while canonical bridge withdrawals can take up to 7 days. You can check the status of your transactions in DecentScan by clicking the Transactions link in the Portal, or by visiting [Decent Scan](https://www.decentscan.xyz/) and entering your wallet address. ### How do I claim a canonical bridge withdrawal after the 7-day waiting period? ➔ If your withdrawal is ready to be claimed, a notification icon will appear within the Portal when the correct wallet is connected. Go to the Bridge tab, open the notification, and follow the link to claim your withdrawal on [Decent Scan](https://www.decentscan.xyz/) . Alternatively, you can monitor your transaction in Decent Scan and claim your withdrawal directly from their interface. ### Why is my transaction gas fee high? ➔ If your gas fee seems unusually high, it could be due to network congestion or insufficient funds to cover both the transaction value and gas costs. You may want to try reducing the transaction amount or reviewing your gas settings. Note: We recommend only advanced users customize their gas settings. Incorrectly adjusting gas fees can lead to delays or failed transactions. For most users, it's best to leave the default gas settings or select one of the speed options provided by your web3 wallet. ### What are the Ape Portal platform transaction fees? ➔ | Fees | | | --- | --- | | Bridge | 0.12% plus $0.20, with no fees for ApeChain canonical bridge routes. | | Swap | 0.25% plus $0.20. | | Onramp | 1.00%. | Note: Platform transaction fees may vary by product and are subject to change based on network conditions, liquidity availability, or other external factors. While we strive to keep fees consistent, higher fees may occasionally apply in certain situations. Always review all transaction fees by clicking the dropdown before initiating any transactions. Please also note that the Ape Portal Onramp fee is in addition to the Moonpay or Transak onramp fee, which is set by the onramp provider. ### How do I see the status of my transaction? ➔ There are several ways to track your transaction status: After submitting a transaction, click the "View Transaction" button to track its status on [Decent Scan](https://www.decentscan.xyz/) . For transactions on ApeChain, visit [ApeScan](https://apescan.io/) and enter your transaction hash. For all other transactions, visit [Decent Scan](https://www.decentscan.xyz/) and paste your transaction hash. Note: If you don’t know your transaction hash, you can find your transactions on both ApeScan and DecentScan by pasting in your wallet address. ### What is slippage tolerance? ➔ Slippage tolerance refers to the maximum percentage difference you're willing to accept between the expected price of a token swap and the actual price at which the swap is executed. If the market price moves beyond your set tolerance during the transaction, it will not complete. For most users, a default slippage tolerance of 1% works well. However, in highly volatile markets or low liquidity situations, you may need to adjust the tolerance to ensure your transaction goes through. Note: Be cautious when increasing slippage tolerance. Setting it too high may result in less favorable trade rates, potentially leading to losses. It is generally advisable to keep slippage low unless you are familiar with the risks. ### What if my transaction fails? ➔ If your transaction fails, check your wallet on the originating network to confirm whether your tokens have been returned. In most cases, failed transactions automatically result in the tokens being returned to your wallet. Be sure to carefully review any warnings in the Ape Portal or your Web3 wallet before signing a transaction. ### Why would my transaction fail? ➔ Transaction failures typically occur when gas prices spike unexpectedly or when the slippage tolerance is set too low. Ensure your gas settings are sufficient, and adjust the slippage tolerance if necessary. ⚠️ Note: Be cautious when manually adjusting slippage tolerance. A lower tolerance may prevent the transaction from completing if the price fluctuates too much, which is intentional to protect against unfavorable trades. ### My transaction says it is confirmed, but I don’t see the tokens. Where are they? ➔ Occasionally, there may be a delay in reflecting transactions in your balance due to network congestion. Check the [ApeScan](https://apescan.io/) or [Decent Scan](https://www.decentscan.xyz/) for real-time transaction updates. ### What are the warning or error messages? ➔ **INSUFFICIENT FUNDS:** You don’t have enough of the "From" token to complete a bridge or swap transaction, or you're lacking the native gas token on the "From" network. For example, bridging or swapping $APE ERC-20 on Ethereum requires both $APE and $ETH, as $ETH is used to pay for gas fees. **BAD FROM OR TO CHAINS:** This error indicates that the source and destination chains are incompatible (e.g., using a Mainnet chain for the "From" network and a Testnet chain for the "To" network). Solution: Ensure both chains are compatible (e.g., both Mainnet or both Testnet). **SOMETHING WENT WRONG:** This may occur due to network issues, or the Decent.xyz API might be temporarily unavailable. Try again with a different combination of tokens or networks. --- # Subgraphs - ApeChain Docs Subgraphs The Graph Network[](https://docs.apechain.com/subgraphs#the-graph-network) --------------------------------------------------------------------------- Getting historical data on a smart contract can be frustrating when building a dapp. [The Graph (opens in a new tab)](https://thegraph.com/) provides an easy way to query smart contract data through APIs known as subgraphs. The Graph's infrastructure relies on a decentralized network of Indexers, enabling your dapp to become truly decentralized. With The Graph, you can benefit from: * **Decentralized Indexing, Built to Scale**: Tap into a global network of Indexers to efficiently index blockchain data with no single point of failure–just resilient infrastructure. * **Powerful GraphQL Interface**: Query blockchain data using GraphQL. It's fast and flexible, accelerating data retrieval to enhance your dapps. * **Customizable Data Logic**: Define your own logic for transforming and storing blockchain data. Reuse subgraphs published by other developers on The Graph Network. Supported Networks * ApeChain Mainnet * ApeChain Curtis Testnet ### Quick Start[](https://docs.apechain.com/subgraphs#quick-start) These subgraphs only take a few minutes to set up. Follow this [quick-start (opens in a new tab)](https://thegraph.com/docs/en/quick-start/) guide to create, deploy, and query a subgraph within 5 minutes. Pricing: **All developers receive 100K free monthly queries on the decentralized network**. After these free queries, you only pay based on usage at $2 for every 100K queries. Ormi[](https://docs.apechain.com/subgraphs#ormi) ------------------------------------------------- [Ormi (opens in a new tab)](https://www.ormilabs.xyz/) powers ApeChain subgraphs which are fully compatible with The Graph's hosted and decentralized networks, adhering to the same specifications. They seamlessly index data from both the ApeChain mainnet and testnets, allowing developers to easily build applications for ApeChain. Read more on how to create your [account](https://docs.apechain.com/apechain.0xgraph.xyz) deploy your own [subgraph (opens in a new tab)](https://docs.ormi.xyz/apechain-subgraphs) on ApeChain. For developers who are already familiar with Graph Protocol tooling, below are the network definitions to deploy subgraphs on ApeChain. These settings can be configured in the subgraph.yaml file. | Network | | | --- | --- | | Mainnet | `network: 'apechain'` | | Curtis | `network: 'apechain-curtis'` | Goldsky[](https://docs.apechain.com/subgraphs#goldsky) ------------------------------------------------------- ​ Goldsky is ApeChain's trusted partner for high-performance data indexing and streaming, making it easy for developers to power dApps, analytics, and AI agents with fast, reliable access to ApeChain's on-chain data. Goldsky offers **two powerful products**: ### Subgraphs[](https://docs.apechain.com/subgraphs#subgraphs) [Subgraphs (opens in a new tab)](https://docs.goldsky.com/subgraphs/deploying-subgraphs) allow you to index ApeChain data into a highly optimized format for **instant, flexible querying**. Use subgraphs when you want to **read and display on-chain data** inside apps, websites, dashboards, bots, and more. * **Ultra-fast reads**: Query large volumes of on-chain data with millisecond response times. * **Flexible GraphQL APIs**: Filter, paginate, and fetch exactly the data you need. * **Custom indexing logic**: Handle complex event processing, join entities, build derived fields. * **Auto-scaling**: Goldsky automatically scales infrastructure for you, no more worrying about node ops. * **Instant Deployment**: Create subgraphs instantly by uploading your ABI and contract address, no GraphQL coding required (but you can fully customize if you want). 🛠️ **Example Use Cases**: * NFT marketplaces (fetching listings, offers, metadata) * DeFi dashboards (tracking TVL, trades, positions) * Social apps (aggregating profiles, posts, on-chain actions) * In-game marketplaces (real-time item trades and player stats) ### Mirror[](https://docs.apechain.com/subgraphs#mirror) [Mirror (opens in a new tab)](https://docs.goldsky.com/mirror/create-a-pipeline) is a real-time data streaming pipeline that **replicates ApeChain data into your own database**, letting you power complex backends, machine learning, or data analytics. * **Real-time streaming**: Ingest new blocks, events, transactions as they happen. * **Your schema, your rules**: Mirror supports flexible transformations and customizations. * **Database integration**: Push to Postgres, Clickhouse, or your warehouse of choice. * **Perfect for AI/ML**: Build embeddings, train models, and run inference on live blockchain data. 🛠️ **Example Use Cases**: * Powering AI agents with up-to-the-second on-chain awareness * Building custom analytics dashboards * Enabling real-time alerts and risk monitoring systems * Aggregating on-chain activity into internal data lakes Why Goldsky for ApeChain Builders?[](https://docs.apechain.com/subgraphs#why-goldsky-for-apechain-builders) ------------------------------------------------------------------------------------------------------------ * Lightning-fast query speeds * Real-time data pipelines * No need to manage indexers or infra * Instant onboarding with minimal config * Trusted by major Web3 projects across DeFi, gaming, AI, and social | Network | Subgraphs | Mirror | | --- | --- | --- | | Mainnet | ✅ | ✅ | | Curtis | ✅ | ✅ | ### How to Get Started[](https://docs.apechain.com/subgraphs#how-to-get-started) Goldsky makes it fast and easy to launch a subgraph or pipeline: * **Deploy via CLI**: Create fully custom subgraphs or Mirror configs from your local setup. * **Instant deployment**: Just upload your contract ABI + address, and Goldsky generates a working subgraph for you in minutes, no GraphQL coding needed. ### Demo: Intro to Indexing with Goldsky[](https://docs.apechain.com/subgraphs#demo-intro-to-indexing-with-goldsky) 👉 [**Follow the full step-by-step guide here** (opens in a new tab)](https://docs.goldsky.com/chains/apechain?utm_source=apechain&utm_medium=docs) to deploy on ApeChain. If you need help designing your schema or choosing between Subgraphs and Mirror, [**reach out to the Goldsky team** (opens in a new tab)](https://docs.goldsky.com/getting-support) — they're happy to guide you. ---