Xai 백서

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

have all the features you need to build a fully functional marketplace. In addition, we have an [open source custom marketplace boilerplate](https://github.com/0xsequence/marketplace-boilerplate) that you can readily use for your project based on our whitelabel marketplace so you don’t need to build from scratch. 💡 Sequence Market contract is fully audited and can be found at <https://github.com/0xsequence/marketplace-contracts> For more resources on leveraging the Sequence Market Protocol, check out the [in-depth documentation](https://docs.sequence.xyz/api/marketplace/examples/orderbook-transactions). #### Walkthrough Lastly, take a look at Sequence’s [end to end guide](https://docs.sequence.xyz/guides/custom-marketplace) to get you off the ground running with your own marketplace & learn about the infrastructure that powers Sequence. This guide leverages several components of the sequence stack such as our Marketplace APIs and Indexer - all the components needed for accelerating development time & building a scalable in-game or browser based marketplace. </details> <details> <summary>Smart Contract Suite</summary> Xai Builder simplifies smart contract deployment and management with a suite of user-friendly features. Import, deploy, and add contract collaborators to a smart contract in the contracts dashboard and interact directly with your contract. #### What are my deployment options? Deployment of contracts with Xai Builder is simplified through a streamlined process directly within our dashboard. Choose from various contract templates (ERC1155, ERC721, ERC20) and more. The Xai Builder also gives you the option to upload your own custom contracts - saved to your project to deploy to the Xai network. You can check out more information on the deployable contracts through Xai Builder from the link [here](https://docs.sequence.xyz/solutions/builder/contracts). </details> [^1]: Seems to refer to the overall section rather than this specific step [^2]: Redundant from heading [^3]: Seems to not match the step i.e. Review T\&Cs [^4]: Maybe define "what is a project" here. This seems to say Projects are important but not why [^5]: This should be made specific to are you creating a project for mainnet or testnet i.e. Xai or Xai Sepolia [^6]: might be confusing compared to Sequence Embedded wallet. Maybe should be introduced before Sequence Embedded Wallet as the overall product from Sequence? # Subgraph Goldsky is a powerful subgraph provider that allows game developers to efficiently query blockchain data on Xai. By leveraging Goldsky, you can access real-time data for both the testnet and mainnet environments, enabling seamless integration and enhanced functionality for your games. **Why Use Goldsky Subgraphs?** Subgraphs are essential for indexing and querying blockchain data quickly and efficiently. Goldsky provides robust and scalable subgraph solutions, making it easier to interact with complex blockchain data structures. Key benefits include: * **Real-time Data Access:** Obtain up-to-date information from the blockchain, ensuring your game logic remains current and accurate. * **Efficient Queries:** Optimize your data retrieval processes with high-performance querying capabilities. * **Seamless Integration:** Easily integrate subgraph data into your game development workflows. **Accessing Goldsky Subgraphs** Goldsky provides endpoints for both the Xai testnet and mainnet, allowing you to test and deploy your game with reliable data sources. **Testnet Subgraph** To access the Xai testnet subgraph, use the following endpoint: ```bash bashCopy codehttps://api.goldsky.com/api/public/project_cl8ylkiw00krx0hvza0qw17vn/subgraphs/blocks/xai-sepolia/gn ``` This endpoint provides access to testnet data, enabling you to develop and test your game in a safe environment before deploying to mainnet. **Mainnet Subgraph** For live data on the Xai mainnet, use this endpoint: ```bash bashCopy codehttps://api.goldsky.com/api/public/project_cl8ylkiw00krx0hvza0qw17vn/subgraphs/blocks/xai/gn ``` This endpoint ensures you can access real-time mainnet data, crucial for deploying your game to production with accurate and reliable information. **How to Use Goldsky Subgraphs** 1. **Setup Your Environment:** Ensure your development environment is configured to make HTTP requests. Common tools include cURL, Postman, or integrated directly within your codebase using libraries like Axios (JavaScript) or Requests (Python). 2. **Querying Data:** Construct your GraphQL queries to fetch the necessary data from the subgraphs. Here is a basic example of a GraphQL query to get block information: ```graphql graphqlCopy code{ blocks(first: 5) { id number timestamp } } ``` 3. **Integrating into Your Game:** Use the data retrieved from Goldsky subgraphs to enhance your game logic. Whether you need player stats, game state information, or other blockchain-related data, subgraphs provide a reliable source. 4. **Testing:** Always test your queries on the testnet first to ensure they return the expected data. Once validated, you can confidently switch to the mainnet endpoint for production. **Additional Resources** For more detailed information and advanced usage, refer to the Goldsky documentation: * [Goldsky Documentation](https://docs.goldsky.com/chains/xai) By leveraging Goldsky subgraphs, you can build more dynamic, data-driven games on the Xai blockchain, ensuring a smooth and enriched gaming experience for your users. # Xai Gas Subsidy ## XAI Gas Subsidy The XAI Gas Subsidy uses the ERC-2771 standard for secure protocol for native meta transactions. With the XAI Gas Subsidy XAI can sponsor your user's transactions so they don't have to own native XAI. ### How the XAI Gas Subsidy works Instead of using a contract write function, the user will sign a typed data message ([EIP-712](https://eips.ethereum.org/EIPS/eip-712)) with the message implementing the [ERC-2771](https://eips.ethereum.org/EIPS/eip-2771) `meta-transaction`. This means when you use the XAI Gas Subsidy your user does not call the contract directly, instead the XAI relayer will forward to your smart contract. #### Relayer Endpoints: **Xai Mainnet Relayer**: <https://relayer.xai.games/\\> **Xai Mainnet API Docs**: <https://docs.xai.games/gas-relayer/#/relayer> **Xai Testnet Relayer**: <https://develop.relayer.xai.games/> \ **Xai Testnet API Docs**: <https://develop.docs.xai.games/gas-relayer/#/relayer> ### Requirements To use the XAI Gas Subsidy your contracts need to follow the [ERC-2771](https://eips.ethereum.org/EIPS/eip-2771) \_msgSender() overwrite and make sure to only use the \_msgSender() when updating a user's state. \ \ The [ERC-2771](https://eips.ethereum.org/EIPS/eip-2771) requires the validation for a trusted forwarder contract when interacting on behalf of a user. The **trusted forwarder contract for your ecosystem's contracts should be owned by you**. The trusted forwarder contract will be able to execute transactions on behalf of your user's wallet.\ \ Interacting with ERC-20 tokens while using the Xai subsidy requires implementing the ERC-2771 standard. Gasless approvals can be achieved by implementing the ERC-2612 Permit Extension. **Any ERC-20 contracts that don't either implement ERC-2771 or ERC-2612 can not be used for sponsored transaction.**\ \ **FOR ALL INTERACTIONS ALLOWING THE FORWARDER, DO NOT USE `msg.sender` IN YOUR CONTRACTS, YOU MUST USE `_msgSender()` or your contract's state will not be updated properly**\ \ For **testing purposes** there is a Xai mainnet and testnet forwarder deployed: * **Xai mainnet 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.&#x20; ### **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.&#x20; ### **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&#x20; * @jasonCHY&#x20; * @jimmyj506&#x20; * @IDefleqt&#x20; * @Gaiens&#x20; * @Allyvic&#x20; * @beep420&#x20; * @Thomas88888&#x20; * @XAICommunity\_Bot&#x20; ### **Trusted Xai Admins on Discord** * diabloxp&#x20; * 0xblasco&#x20; ### **Communication Blackout** To prevent misinformation, messaging in both Telegram & Discord will be DISABLED 30 minutes before the token claim starts.&#x20; ### **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.&#x20; ### **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/en/xai-vanguard-previous-seasons/archive/minting-xai-quest-token/step-1-obtain-testnet-eth-on-goerli) ## [Step 2: Obtain testnet ETH on A
프로젝트로 돌아가기