bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 8쪽 중 4쪽
Bridge (ETH)
Relay enables instant, low-cost bridging and cross-chain execution.
1. Access the [Relay Bridge](https://relay.link/bridge/ancient8/).
2. Connect your wallet.
3. Select the asset as ETH.
4. Specify the desired amount for deposit or withdrawal.
*\*USDC support coming soon.*
<figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FI6xaDOn3oCWuVYsDeSvj%2Fimage.png?alt=media&token=34910ef4-b535-4ebc-a692-78d4a3055f6b" alt=""><figcaption></figcaption></figure>
## Ancient8 Testnet Bridge
> The [Ancient8 Testnet Bridge](https://bridge-testnet.ancient8.gg/) allows you to bridge ETH from **Ethereum Sepolia** to Ancient8 Testnet and vice versa.
To bridge to or from Ancient8 Testnet:
1. Visit [Ancient8 Testnet Bridge](https://bridge-testnet.ancient8.gg/).
2. Connect your wallet.
3. Select your bridge assets.
4. Choose the amount of ETH (or the asset of your choice that's available) you'd like to deposit or withdraw.
<figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2FdEqyGo4xbB0u05wu6zbb%2FScreenshot%202024-09-20%20at%2012.35.22.png?alt=media&token=6b12a736-a427-4c55-8453-ba9437f6956a" alt=""><figcaption></figcaption></figure>
# Block Explorers
### Routescan <a href="#blockscout" id="blockscout"></a>
Routescan supports Ancient8 Block Explorer:
Ancient8 Mainnet Explorer Routescan: <https://ancient8.routescan.io/>
1. **Real-Time Insights:** Track identities, view badges, and monitor credentials with unparalleled clarity.
2. **Empowering Developers:** Access comprehensive data and advanced analytics using Galxe’s APIs, RPCs, and Credential Verification tools.
3. **Data Visualization:** Create, customize, and share charts to compare identity volumes, badge issuance, and other critical data points.
4. **Multichain API:** Access hundreds of thousands of API calls across multiple chains with a single key for deep blockchain analytics.
5. **Bulk Data Export:** Export up to 10,000 identity records, with plans to include badge and credential exports.
6. **Custom Charts:** Flexible options for visualizing data with various resolutions, scales, styles, colors, and timeframes.
Routescan is the world's first unified multichain explorer, offering innovative Explorer as a Service solutions with 48h Fast Indexing and Full History APIs.
### Blockscout <a href="#blockscout" id="blockscout"></a>
A8Scan is based out from Blockscout and it provides tools to help you debug smart contracts and transactions:
1. View, verify, and interact with smart contract source code.
2. View detailed transaction information.
Ancient8 Mainnet: <https://scan.ancient8.gg/>
Ancient8 Testnet: <https://scanv2-testnet.ancient8.gg/>
# Faucet
## Direct Faucet <a href="#blockscout" id="blockscout"></a>
### [Direct Thirdweb - Ancient8 Testnet Faucet ](https://thirdweb.com/ancient8-testnet) <a href="#blockscout" id="blockscout"></a>
You can request directly 0.1 ETH on Ancient8 Testnet via Thirdweb every 24 hours.
## Sepolia Faucet and Bridge to Ancient8 Testnet
Get Sepolia ETH from here and bridge to Ancient8 Testnet
### [Alchemy's Sepolia Faucet ](https://sepoliafaucet.com/) <a href="#blockscout" id="blockscout"></a>
You can request 0.5 ETH from this faucet every 24 hours.
{% hint style="info" %}
Email sign-up is required to use this faucet. You do not need Mainnet ETH.
{% endhint %}
### [QuickNode Sepolia Faucet](https://faucet.quicknode.com/ethereum/sepolia) <a href="#quicknode-sepolia-faucet" id="quicknode-sepolia-faucet"></a>
You can request Sepolia ETH quickly by connecting your wallet.
{% hint style="info" %}
You must hold 0.01 ETH on Mainnet to use this faucet and can get 2x the ETH if you share a tweet.
{% endhint %}
\
Follow the steps in [Bridges](/using-ancient8-chain/bridges) to get tokens into our testnet.
# Deploying Smart Contracts
This tutorial will teach you on how to deploy smart contracts on Ancient8 Chain. You can choose the following tools:
* [Using Hardhat](/building-on-ancient8/deploying-smart-contracts/using-hardhat)
* [Using Remix](/building-on-ancient8/deploying-smart-contracts/using-remix)
* [Using thirdweb](/building-on-ancient8/deploying-smart-contracts/using-thirdweb)
# Using Hardhat
Hardhat is an Ethereum development environment for flexible, extensible, and fast smart contract development.
You can use Hardhat to edit, compile, debug, and deploy your smart contracts to Ancient8.
## Using Hardhat
This section will guide you through deploying an NFT smart contract (ERC-721) on the Ancient8 test network using [Hardhat](https://hardhat.org/).
### Objectives <a href="#objectives" id="objectives"></a>
By the end of this guide you should be able to do the following:
* Setup Hardhat for Ancient8 Testnet
* Create an NFT smart contract for Ancient8 Testnet
* Compile a smart contract for Ancient8 Testnet
* Deploy a smart contract to Ancient8 Testnet
* Interact with a smart contract deployed on Ancient8 Testnet
### Prerequisites <a href="#prerequisites" id="prerequisites"></a>
#### Node v18+
This guide requires you have Node version 18+ installed.
#### Wallet funds?
Deploying contracts to the blockchain requires a gas fee. Therefore, you will need to fund your wallet with **Sepolia ETH** to cover those gas fees.
### Creating a project <a href="#creating-a-project" id="creating-a-project"></a>
Before you can begin deploying smart contracts to Ancient8 Testnet, you need to set up your development environment by creating a Node.js project.
To create a new Node.js project, run:
```
npm init --y
```
Next, you will need to install Hardhat and create a new Hardhat project
To install Hardhat, run:
```
npm install --save-dev hardhat
```
To create a new Hardhat project, run:
```
npx hardhat
```
Select Create a TypeScript project then press enter to confirm the project root.
Select y for both adding a .gitignore and loading the sample project. It will take a moment for the project setup process to complete.
### Configuring Hardhat with Ancient8 <a href="#configuring-hardhat-with-base" id="configuring-hardhat-with-base"></a>
In order to deploy smart contracts to the Ancient8 Testnet, you will need to configure your Hardhat project and add the Ancient8 Testnet.
To configure Hardhat to use Ancient8 Testnet, add Ancient8 Testnet as a network to your project's `hardhat.config.ts` file:
```javascript
import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
require('dotenv').config();
const config: HardhatUserConfig = {
solidity: {
version: '0.8.17',
},
networks: {
// for testnet
'a8-testnet': {
url: 'https://rpc-testnet.ancient8.gg',
accounts: [process.env.WALLET_KEY as string],
gasPrice: 1000000000,
},
},
defaultNetwork: 'a8-testnet',
};
export default config;
```
#### Install Hardhat toolbox[](https://docs.base.org/guides/deploy-smart-contracts#install-hardhat-toolbox) <a href="#install-hardhat-toolbox" id="install-hardhat-toolbox"></a>
The above configuration uses the `@nomicfoundation/hardhat-toolbox` plugin to bundle all the commonly used packages and Hardhat plugins recommended to start developing with Hardhat.
To install `@nomicfoundation/hardhat-toolbox`, run:
```
npm install --save-dev @nomicfoundation/hardhat-toolbox
```
#### Loading environment variables <a href="#loading-environment-variables" id="loading-environment-variables"></a>
The above configuration also uses [dotenv](https://www.npmjs.com/package/dotenv) to load the `WALLET_KEY` environment variable from a `.env` file to `process.env.WALLET_KEY`. You should use a similar method to avoid hardcoding your private keys within your source code.
To install `dotenv`, run:
```
npm install --save-dev dotenv
```
Once you have `dotenv` installed, you can create a `.env` file with the following content:
```
WALLET_KEY=<YOUR_PRIVATE_KEY>
```
Substituting `<YOUR_PRIVATE_KEY>` with the private key for your wallet.
{% hint style="warning" %}
**CAUTION**
`WALLET_KEY` is the private key of the wallet to use when deploying a contract. For instructions on how to get your private key from Metamask, visit the [Metamask documentation](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key). **It is critical that you do NOT commit this to a public repo**
{% endhint %}
### Compiling the smart contract <a href="#compiling-the-smart-contract" id="compiling-the-smart-contract"></a>
Below is a simple NFT smart contract (ERC-721) written in the Solidity programming language:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract NFT is ERC721 {
using Counters for Counters.Counter;
Counters.Counter private currentTokenId;
constructor() ERC721("NFT Name", "NFT") {}
function mint(address recipient)
public
returns (uint256)
{
currentTokenId.increment();
uint256 tokenId = currentTokenId.current();
_safeMint(recipient, tokenId);
return tokenId;
}
}
```
The Solidity code above defines a smart contract named `NFT`. The code uses the `ERC721` interface provided by the [OpenZeppelin Contracts library](https://docs.openzeppelin.com/contracts/4.x/) to create an NFT smart contract. OpenZeppelin allows developers to leverage battle-tested smart contract implementations that adhere to official ERC standards.
To add the OpenZeppelin Contracts library to your project, run:
```sh
npm install --save @openzeppelin/contracts
```
In your project, delete the `contracts/Lock.sol` contract that was generated with the project and add the above code in a new file called `contracts/NFT.sol`. (You can also delete the `test/Lock.ts` test file, but you should add your own tests ASAP!).
To compile the contract using Hardhat, run:
```shell
npx hardhat compile
```
### Deploying the smart contract <a href="#deploying-the-smart-contract" id="deploying-the-smart-contract"></a>
Once your contract has been successfully compiled, you can deploy the contract to the Ancient8 Testnet.
To deploy the contract to the Ancient8 Testnet, you'll need to modify the `scripts/deploy.ts` in your project:
```typescript
import { ethers } from 'hardhat';
async function main() {
const nft = await ethers.deployContract('NFT');
await nft.waitForDeployment();
console.log('NFT Contract Deployed at ' + nft.target);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
```
You'll also need **Sepolia ETH** in your wallet. See the [prerequisites](#prerequisites) if you haven't done that yet. Otherwise, the deployment attempt will fail.
Finally, run:
```bash
npx hardhat run scripts/deploy.ts
```
The contract will be deployed on the Ancient8 Testnet. You can view the deployment status and contract by using a [block explorer](https://testnet.a8scan.io) and searching for the address returned by your deploy script. If you've deployed an exact copy of the NFT contract above, it will already be verified and you'll be able to read and write to the contract using the web interface.
{% hint style="info" %}
**INFO**
If you'd like to deploy to mainnet, you'll modify the command like so:
```
npx hardhat run scripts/deploy.ts --network ancient8-mainnet
```
{% endhint %}
# Using Remix
[Remix](https://remix.ethereum.org/) is an online IDE that you can use to rapidly develop and deploy smart contracts. If you're new to smart contracts, it's a great tool that lets you jump right in without needing to configure a local editor or struggle through environment configuration issues before getting started.
Remix contains a simulation of a blockchain that you can use to rapidly deploy and test your contracts. This simulation only exists within your browser, so you can't share it with others or use external tools or a front end to interact with it. However, you can also deploy to a variety of testnets from within Remix. Doing so will allow you to share your contract with others, at the cost of making it public.
In this article, we'll give you an overview of Remix, and show you how to deploy a contract to **Ancient8 Testnet**.
{% hint style="info" %}
**INFO**
For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've selected **Ancient8 Mainnet** as the network rather than **Ancient8 Testnet**.
{% endhint %}
If you're already familiar with Remix, you probably want to jump down to [here](#prepare-for-deployment).
### Objectives[](https://docs.base.org/guides/deploy-with-remix#objectives) <a href="#objectives" id="objectives"></a>
By the end of this lesson you should be able to:
* List the features, pros, and cons of using Remix as an IDE
* Deploy and test the Storage.sol demo contract in Remix
* Use Remix to deploy a contract to the Ancient8 Testnet and interact with it in Etherscan
### Remix Window Overview[](https://docs.base.org/guides/deploy-with-remix#remix-window-overview) <a href="#remix-window-overview" id="remix-window-overview"></a>
Begin by opening a browser window and navigating to \[remix.ethereum.org]. Click through the introductory tips, then review the editor. It is divided into three areas, which should look familiar.
#### Editor Pane[](https://docs.base.org/guides/deploy-with-remix#editor-pane) <a href="#editor-pane" id="editor-pane"></a>
The editor pane loads with the Remix home screen, which contains news, helpful links, and warnings about common scams. You can close the home tab if you'd like, then open `1_Storage.sol`, located inside the `contracts` folder of the `default_workspace`.
<figure><img src="https://2872752532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzTPAeEr3HyZhmijpV6ll%2Fuploads%2Fn2EXt2LiB7i4TdZS2RVp%2Fimage.png?alt=media&token=9e488781-631e-4e99-be34-04aba09a7174" alt=""><figcaption></figcaption></figure>
You'll edit your code in the editor pane. It also has most of the features you're expecting, such as syntax and error highlighting. Note that in Remix, errors are not underlines. Instead, you'll see an❗to the left of the line number where the error is present.
At the top, you'll see a big green arrow similar to the *Run* button in other editors. In Solidity, this compiles your code, but it does not run it because you must first deploy your code to the simulated blockchain.
#### Terminal/Output[](https://docs.base.org/guides/deploy-with-remix#terminaloutput)
Below the editor pane, you'll find the terminal.

You'll primarily use this panel to observe transaction logs from your smart contracts. It's also one way to access Remix's powerful debugging tools.
#### Left Panel[](https://docs.base.org/guides/deploy-with-remix#left-panel) <a href="#left-panel" id="left-panel"></a>
As with many other editors, the left panel in Remix has a number of vertical tabs that allow you to switch between different tools and functions. You can explore the files in your current workspace, create and switch between workspaces, search your code, and access a number of plugins.
### Plugins[](https://docs.base.org/guides/deploy-with-remix#plugins)
Most of the features in Remix are plugins and the ones you'll use the most are active by default. You can view and manage plugins by clicking the plug button in the lower-left corner, right above the settings gear. You can turn them off and on by clicking activate/deactivate, and some, such as the *Debug* plugin will be automatically activated through other parts of the editor.
#### Solidity Compiler[](https://docs.base.org/guides/deploy-with-remix#solidity-compiler) <a href="#solidity-compiler" id="solidity-compiler"></a>
The first default plugin (after the search function) is the *Solidity Compiler*. Be sure to check the `Auto compile` option. Smart contracts are almost always in very small files, so this shouldn't ever cause a performance problem while editing code.
The `Compile and Run script` button in this plugin is a little misleading. This is **not** how you will usually run your contract through testing. You can click the `I` button for more information on this feature.
Finally, if you have errors in your contracts, the complete text for each error will appear at the bottom of the pane. Try it out by introducing some typos to `1_Storage.sol`.
#### Deploy & Run Transactions[](https://docs.base.org/guides/deploy-with-remix#deploy--run-transactions) <a href="#deploy--run-transactions" id="deploy--run-transactions"></a>
The *Deploy & Run Transactions* plugin is what you'll use to deploy your contracts and then interact with them. At the top are controls to select which virtual machine to use, mock user wallets with test Ether, and a drop down menu to select the contract you wish to deploy and test.
Fix any errors you introduced to `1_Storage.sol` and click the orange `Deploy` button. You'll see your contract appear below as *STORAGE AT \\\<address>*.
{% hint style="warning" %}
**CAUTION**\
There are a couple gotchas that can be very confusing with deploying contracts in Remix.
First, every time you hit the Deploy button, a new copy of your contract is deployed, but the previous deployments remain. Unless you are comparing or debugging between different versions of a contract, or deploying multiple contracts at once, you should click the `Trash` button to erase old deployments before deploying again.
Second, if your code will not compile, **clicking the deploy button will not generate an error!** Instead, the last compiled version will be deployed. Visually check and confirm that there are no errors indicated by a number in a red circle on top of the Compiler plugin.
{% endhint %}
### Prepare for Deployment[](https://docs.base.org/guides/deploy-with-remix#prepare-for-deployment) <a href="#prepare-for-deployment" id="prepare-for-deployment"></a>
Testnets operate in a similar, **but not exactly the same** manner as the main networks they shadow. You need a wallet with the appropriate token to interact with them by deploying a new contract or calling functions in a deployed contract.
#### Set Up a Wallet[](https://docs.base.org/guides/deploy-with-remix#set-up-a-wallet) <a href="#set-up-a-wallet" id="set-up-a-wallet"></a>
If you already have a wallet set up **exclusively for development**, you can skip to the next section. Otherwise, now is the time to jump in!
{% hint style="danger" %}
**DANGER**
It is very dangerous to use a wallet with valuable assets for development. You could easily write code with a bug that transfers the wrong amount of the wrong token to the wrong address. Transactions cannot be reversed once sent!
Be safe and use separate wallets for separate purposes.
{% endhint %}
First, add the [Metamask](https://metamask.io/) wallet to your browser, and set up a new wallet. As a developer, you need to be doubly careful about the security of your wallet! Many dApps grant special powers to the wallet address that is the owner of the contract, such as allowing the withdrawal of all the Ether that customers have paid to the contract, or changing critical settings.
#### Add the Ancient8 Testnet to your Wallet[](https://docs.base.org/guides/deploy-with-remix#add-the-base-goerli-network-to-your-wallet) <a href="#add-the-base-goerli-network-to-your-wallet" id="add-the-base-goerli-network-to-your-wallet"></a>
For this guide, you will be deploying a contract to the Ancient8 Testnet. You can fund your wallet with Ancient8 Testnet Sepolia ETH using the following options:
* [Bridging Sepolia ETH from Ethereum Sepolia ](#bridging-sepolia-eth-from-eth프로젝트로 돌아가기