bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 56쪽 중 17쪽
nnet Forwarder: 0x4AfA378FDDc9829B1D40655ED5EDBCC31404dee6**\
[**https://explorer.xai-chain.net/address/0x4AfA378FDDc9829B1D40655ED5EDBCC31404dee6/contracts#address-tabs**](https://explorer.xai-chain.net/address/0x4AfA378FDDc9829B1D40655ED5EDBCC31404dee6/contracts#address-tabs)
* **Xai testnet Forwarder: 0x31635b37347258d7c6f83bDC664c5516Da8e6fD7** [**https://testnet-explorer-v2.xai-chain.net/address/0x31635b37347258d7c6f83bDC664c5516Da8e6fD7/read-proxy#address-tabs**](https://testnet-explorer-v2.xai-chain.net/address/0x31635b37347258d7c6f83bDC664c5516Da8e6fD7/read-proxy#address-tabs)
The \_msgSender() overrides the default msg.sender. As the default msg.sender would be the address of the forward contract instead of the user wallet address:
```solidity
function _msgSender() internal view returns (address) {
uint256 calldataLength = msg.data.length;
if (isTrustedForwarder(msg.sender) && calldataLength >= 20) {
return address(bytes20(msg.data[calldataLength - 20:]));
} else {
return super._msgSender();
}
}
```
The \_msgDate() overrides the default msg.data:
```solidity
function _msgData() internal view returns (bytes calldata) {
uint256 calldataLength = msg.data.length;
if (isTrustedForwarder(msg.sender) && calldataLength >= 20) {
return msg.data[:calldataLength - 20];
} else {
return super._msgData();
}
}
```
The trusted forwarder check is important to only allow a trusted forwarder contract to call the functions on user's behalf:
```solidity
function isTrustedForwarder( address forwarder ) public view returns (bool) {
return forwarder == trustedForwarder;
}
```
**How to sign meta transactions**
The user needs to signs a message based on the EIP-712 sign typed message using the 2771 forward request standard:
```javascript
export function createTypedData(wallet: `0x${string}`, receiver: `0x${string}`, forwarderAddress: `0x${string}`, nonce: number) {
//Create the data from your smart contract instance
const data = receiverContract.methods.mint(wallet, BigInt(amount)).encodeABI();
const domain = {
name: "Forwarder", // Forwarder typed name (https://eips.ethereum.org/EIPS/eip-2771)
version: '1', // Forwarder typed version (https://eips.ethereum.org/EIPS/eip-2771)
chainId: BigInt(660279), // XAI mainnet
verifyingContract: forwarderAddress, //Forwarder address
} as const;
const message = {
from: wallet, // The user wallet (the wallet that should be msgSender in your contract)
to: receiver, // The address of the contract to call the write function from
value: BigInt(0), // Value has to be 0, the XAI Relayer can only sponsor transaction fees
gas: BigInt(DEFAULT_GAS), // The expected transaction gas costs
nonce: BigInt(nonce), // The nonce for the user on the forwarder contract (https://eips.ethereum.org/EIPS/eip-2771)
data, // The encoded function identifier to define the contract function to
} as const;
const typedData = {
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" },
],
ForwardRequest: [
{ name: "from", type: "address" },
{ name: "to", type: "address" },
{ name: "value", type: "uint256" },
{ name: "gas", type: "uint256" },
{ name: "nonce", type: "uint256" },
{ name: "data", type: "bytes" },
],
},
primaryType: "ForwardRequest",
domain,
message
} as const;
return typedData;
}
```
The nonce must be the latest nonce from the forwarder for the specific user:
```javascript
export const getNonce = async (userWallet: string, forwarderAddress: string): Promise<number> => {
const forwarderContract = new web3.eth.Contract(ForwarderABI, forwarderAddress);
const nonce = await forwarderContract.methods.nonces(userWallet).call();
return Number(nonce);
}
```
Now to sign this typedData we use the EIP-712 standard to get the signature. We use the signTypedData() from wagmi/core:
```javascript
const signature = await signTypedData(config, typedData);
```
### How to forward the meta-transaction to the XAI Relayer API
Use the signed request signature and the raw request body to forward the transaction and get the transaction fee sponsored by the XAI Gas Subsidy:
```javascript
type ForwardRequest = {
from: string;
to: string;
value: string;
gas: string;
nonce: string;
data: string;
signature: string;
forwarderAddress: string;
};
const forwardTransaction = async (
{
typedData, // Typed data from createTypedData()
signature, // user signature from signTypedData()
forwarderAddress // The forwarder address used
}:
{
typedData: TypedData,
signature: string,
forwarderAddress: string
}
) => {
//Create the request body from the meta-transaction object the user signed
const requestBody: ForwardRequest = {
from: typedData.message.from,
to: typedData.message.to,
value: "0",
gas: typedData.message.gas,
nonce: typedData.message.nonce,
data: typedData.message.data,
signature,
forwarderAddress
}
try {
const res = await fetch(`https://relayer.xai.games/forward/[YOUR_PROJECT_ID]`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.message);
}
console.log("Transaction complete: ", data.txHash)
} catch (error) {
console.error('Error fetching data:', error);
alert("Error sending to relayer\n" + error);
}
}
```
The request will return the transaction hash as a success response or an error string if the transaction would fail or the user has not enough balance left for their sponsoring with your project.
You can request the users current balance from a GET request to the XAI Relayer API `https://relayer.xai.games/quota/[YOUR_PROJECT_ID]/[USER_WALLET]` This will return the user's quota Object:
```json
{
balanceWei: string; // The remaining amount for a user that you pay for his transaction gas
nextRefillTimestamp: number; // The next moment the balance gets refilled
nextRefillAmountWei: string; // The amount of wei that gets refilled on the next refill
lastRefillTimestamp: number; // The last time the balance for a user got refilled
}
```
### Get a Xai Subsidy ProjectID
Contact us on our Discord or Telegram channels to get your ProjectID.
# XAI Token Claim
{% hint style="danger" %}
:rotating\_light: IMPORTANT: XAI TOKEN CLAIM SAFETY ALERT :rotating\_light:
As we approach the XAI token claim, it's crucial to stay vigilant against potential scams. Please carefully read and follow the guidelines below.
{% endhint %}
### **Official XAI Token Claim Contract Address**
The ONLY legitimate XAI token claim contract address is 0x149107dEB70b9514930d8e454Fc32E77C5ABafE0. Any other contract address claiming to be associated with the XAI Token Claim is a SCAM. 
### **Official XAI Token Contract Address**
The ONLY legitimate XAI token contract address is 0x4Cb9a7AE498CEDcBb5EAe9f25736aE7d428C9D66. Any other contract address claiming to be associated with XAI is a SCAM. 
### **Official XAI Token Claim Website**
The ONLY legitimate XAI token claim website is <https://sentry.xai.games/#/claim-token>.
### **Official Start Time**
The XAI Token Claim officially begins at 9:30am UTC (1:30am PST) on Tuesday, January 9, 2024. Do not attempt to claim tokens from any source prior to that start time.
### **Trust Admins Only**
Trust messages ONLY from our admins in Discord and Telegram (list of admins below). Any other sources of the claim contract or website URL, including DMs from unknown users or users pretending to be admins, could be fraudulent.
### **Trusted Xai Admins on Telegram**
* @dblama 
* @jasonCHY 
* @jimmyj506 
* @IDefleqt 
* @Gaiens 
* @Allyvic 
* @beep420 
* @Thomas88888 
* @XAICommunity\_Bot 
### **Trusted Xai Admins on Discord**
* diabloxp 
* 0xblasco 
### **Communication Blackout**
To prevent misinformation, messaging in both Telegram & Discord will be DISABLED 30 minutes before the token claim starts. 
### **Regular Reminders**
Every 10 minutes, an admin will repost this safety message in the general chat on both platforms to keep everyone informed and alert. 
### **Verified Social Media Links**
* Discord: <https://discord.com/invite/k6K6bA6T6F>
* Twitter: <https://twitter.com/XAI_GAMES>
* Telegram: <https://t.me/XaiSentryNodes>
### **Beware of Imposters**
If you receive a DM or encounter a message in any forum from anyone other than the listed admins, DO NOT trust that user.
### **Final Reminder**
Once again, the ONLY real XAI token claim contract address is 0x149107dEB70b9514930d8e454Fc32E77C5ABafE0.
{% hint style="danger" %}
Stay safe and vigilant!
Remember, the safety and security of our community members are our top priority. Let's work together to make the XAI token claim a smooth and secure process.
{% endhint %}
# Claim Details
### Claim Start & End
* Start Time: Tuesday, 01/09/24, at 1:30am PST (9:30am UTC)
* End Time: Sunday, 07/07/24, at 2:30am PDT (9:30am UTC)
### Eligibility Criteria
To be eligible, you must meet at least one of the following criteria:
* Hold an Odyssey Phase 1 NFT (specifically, Legendary & Vanguard tiers).
* Hold an Odyssey Phase 2 NFT (specifically, Legendary & Vanguard tiers).
* Hold at least one Sentry Key NFT.
{% hint style="info" %}
Snapshot for Sentry Key NFTs was taken on 12/28/23 at 12pm PT (8pm UTC)
{% endhint %}
### **Requirements Based on NFTs Held**
* Odyssey NFTs Only (Phase 1/2): If you hold only Odyssey NFT(s), you can claim XAI tokens without KYC. You are exempt from KYC because you did not pay to be eligible for an airdrop.
* Sentry Key NFT Holders: If you hold Sentry Key NFT(s), you are required to pass KYC before you can claim XAI tokens.
* Holders of Both Odyssey and Sentry Key NFTs: If you hold both Odyssey NFT(s) and Sentry Key NFT(s), you must pass KYC to claim any tokens, including those based on the Odyssey NFT(s).
### Compliance Requirements
* You must not be located in any OFAC-sanctioned country.
* You must not be located in the USA.
* You must not be on a sanctioned wallet list.
* You must agree to [Xai Airdrop Terms](https://sentry.xai.games/#/xai-airdrop-terms-and-conditions)
### **KYC Completion Window**
You have up to 180 days from the claim start date to complete your KYC and claim your XAI tokens.
### Steps to Claim
1. Visit <https://sentry.xai.games/#/claim-token>
2. Connect your wallet (via Wallet Connect - similar to Sentry Key purchase)
{% hint style="info" %}
* if the user connects any wallet other than Arbitrum One, they will not be able to proceed with the claim
* If the user is not eligible to claim XAI, the UI will update to tell them they are ineligible
{% endhint %}
3. If you are eligible to claim XAI, you will see a message that says “You are eligible to claim \[xxxx] XAI tokens”
4. Check the box indicating you agree to the [Xai Airdrop Terms](https://sentry.xai.games/#/xai-airdrop-terms-and-conditions)
5. Click “Claim”
6. Approve the transaction request using your wallet (you are responsible for the gas fee to claim using AETH)
{% hint style="info" %}
Once the transaction has completed, you'll see:
* “Transaction complete” confirmation
* the number of eligible tokens decrease by the claimed amount
{% endhint %}
# Archive
# Minting Xai Quest Token
By obtaining a Xai Quest Token, you will be completing this [Galxe quest](https://galxe.com/credential/318855190556614656). Follow the steps below to unlock this achievement and earn points.
{% hint style="info" %}
* If you already hold testnet ETH on Goerli, skip to [Step 2](https://app.gitbook.com/o/BuoxrWWQSBf1z1GsXyfI/s/hE4weeNpCJSNUXnecN1R/~/changes/14/xai-odyssey/xai-odyssey-quick-start/obtaining-xai-quest-token/step-2-obtain-testnet-eth-on-arbitrum-goerli).
* If you already hold testnet ETH on Arbitrum Goerli, skip to [Step 3](https://app.gitbook.com/o/BuoxrWWQSBf1z1GsXyfI/s/hE4weeNpCJSNUXnecN1R/~/changes/14/xai-odyssey/xai-odyssey-quick-start/obtaining-xai-quest-token/step-3-obtain-testnet-eth-on-xai-goerli).
{% endhint %}
## [Step 1: Obtain testnet ETH on Goerli](/xai-network/xai-vanguard-previous-seasons/archive/minting-xai-quest-token/step-1-obtain-testnet-eth-on-goerli)
## [Step 2: Obtain testnet ETH on Arbitrum Goerli](/xai-network/xai-vanguard-previous-seasons/archive/minting-xai-quest-token/step-2-obtain-testnet-eth-on-arbitrum-goerli)
## [Step 3: Obtain testnet ETH on Xai Testnet](/xai-network/xai-vanguard-previous-seasons/archive/minting-xai-quest-token/step-3-obtain-testnet-eth-on-xai-testnet)
## [Step 4: Swap Xai Goerli ETH for Xai Quest Token](/xai-network/xai-vanguard-previous-seasons/archive/minting-xai-quest-token/step-4-mint-xai-quest-token)
# Step 1: Obtain testnet ETH on Goerli
There are two ways to obtain testnet ETH on Goerli
## Option A: Bridge ETH from Ethereum --> Goerli
LayerZero has developed a tool that allows you to bridge ETH from Ethereum network to Goerli network here: [testnetbridge.com](http://testnetbridge.com/)
{% hint style="warning" %}
* This tool will cost you gas in ETH, which can cost around $13 USD.
* Only \~0.000068 ETH on Ethereum Network is required to obtain \~1 ETH on Goerli Nework.
{% endhint %}

* Specify the amount of ETH you want to swap for Goerli

* Accept the transaction in your wallet
## Option B: Mint Goerli ETH from a faucet
{% hint style="warning" %}
* This is a very slow mining process. It is best to stop minting after 6 hours to ensure the tool does not timeout.
* You are severely limited on how much Goerli ETH you can mine, so this process will take more patience if you want to generate at least 1 Goerli ETH for the Galxe quest.
* You must mine at least 0.02 GETH before you can stop the process and mint the mining reward.
{% endhint %}
Visit this website: <https://goerli-faucet.pk910.de/>

* Enter your design wallet address where the Goerli ETH should be minted.

* Once your mining reward reaches a desired amount (at least 0.02 GETH), click "Stop Mining & Claim Rewards"

* Complete the CAPTCHA then click "Claim Rewards"

* Wait for the process to complete

* Confirm Goerli ETH minted in your specified wallet
Once you complete Step 1, proceed to [Step 2](https://app.gitbook.com/o/BuoxrWWQSBf1z1GsXyfI/s/hE4weeNpCJSNUXnecN1R/~/changes/14/xai-odyssey/xai-odyssey-quick-start/obtaining-xai-quest-token/step-2-obtain-testnet-eth-on-arbitrum-goerli).
# Step 2: Obtain testnet ETH on Arbitrum Goerli
There are two ways to obtain testnet ETH on Arbitrum Goerli
## Option A: Bridge GETH from Goerli --> Arbitrum Goerli
Use Arbitrum's website to bridge Goerli ETH (obtained in the previous step) to Arbitrum Goerli: <https://bridge.arbitrum.io/?l2ChainId=421613>
{% hint style="info" %}
Be sure to select **Goerli** in your wallet. Then confirm that the top right corner of the website says "Goerli" as well before proceeding to bridge.
{% endhint %}
<figure><img src="https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Fuploads%2FjXy8Cmm7PocGe4WwEtKL%2Fimage.png?alt=media&token=7995d04c-b3af-4787-b4d1-32f7c797a584" alt=""><figcaption></figcaption></figure>
* Specify the amount of GETH from Goerli you want to bridge to Arbitrum Goerli
* Specify the network you want to bridge to; in this case, "Arbitrum Goerli"
* Click "Move funds to Arbitrum Goerli"
* Confirm the transaction in your wallet
{% hint style="info" %}
It will take \~15 minutes for the bridge from Goerli to Arbitrum Goerli to complete.
{% endhint %}
<figure><img src="https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Fuploads%2FYwwY1JW3DekOQQPw7zfj%2Fimage.png?alt=media&token=8d76b07b-b435-4f1c-a5d3-3e51dd71c31e" alt=""><figcaption></figcaption></figure>
* Once this step is complete, confirm the funds in your wallet (note: be sure to change the network in your wallet to Arbitrum Goerli to see the funds)
### Option B: Mint Arbitrum Goerli ETH from a faucet
Visit this website to mint Aribtrum Goerli directly to your wallet: <https://faucet.quicknode.com/arbitrum/goerli>
{% hint style="warning" %}
* This is a relatively easy process, but you are limited to minting only 0.05 ETH approximately every 2 hours.
* You can mint 0.1 ETH by promoting the faucet through the optional Tweet.
{% endhint %}
# Step 3: Obtain testnet ETH on Xai Testnet
## Steps to bridge testnet ETH from Arbitrum Goerli -> Xai Testnet
Use the following website to bridge Arbitrum Goerli to Xai Testnet: <https://bridge.arbitrum.io/?l2ChainId=47279324479>
{% hint style="info" %}
* Be sure to select **Arbitrum Goerli** in your wallet and then confirm it says "Arbitrum Goerli" in the top right corner of the website.
* If you simply connect to Goerli, or Arbitrum Goerli, the bridge page will automatically switch to the correct testnet view. You'll then be able to see all the corresponding networks in the dropdown, including Xai.
* If you are connected to mainnet, and do not switch networks manually in your wallet, you can enable testnet mode in the bridge by clicking on your address in the top right --> clicking "settings" --> and then "turn on testnet mode". Then Xai will appear in both the network drop down in the top navigation, and as an option in the bridging interface directly.
{% endhint %}
<figure><img src="https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Fuploads%2Fbjh4XeH1gtXqGR3r7a2J%2Fimage.png?alt=media&token=2dc08ccc-c5be-48c3-8d88-1c68218b7ca4" alt=""><figcaption></figcaption></figure>
* Enter the amount of testnet ETH to bridge from Aribtrum Goerli to Xai Testnet
<figure><img src="https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Fuploads%2F4i8FUTCS5YolzJd9VT3c%2Fimage.png?alt=media&token=d1756d1b-f541-4979-91a0-61d697d53da5" alt=""><figcaption></figcaption></figure>
* It may take a few seconds for the transaction to complete
<figure><img src="https://2248955668-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhE4weeNpCJSNUXnecN1R%2Fuploads%2FYgifbwnx852OzJp66aHD%2Fimage.png?alt=media&token=db3ad5f6-6af5-40fe-8042-0f0cfab6ecff" alt=""><figcaption></figcaption></figure>
* This is what you should see when the transaction completes.
# Step 4: Mint Xai Quest Token
If you hold testne프로젝트로 돌아가기