Xai 백서

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

JRq5PqTDUTYG22/image.png" alt="" data-size="original"> #### Marketplace transactions *Marketplace transactions* shows the total number of buy and sell events that occure via the Sequence Marketplace API. <img src="https://content.gitbook.com/content/neke8a6D4Ybg9dkRA2GD/blobs/8UwX7HKy4X74tlTp2UOA/image%20(1).png" alt="" data-size="original"> #### Transaction requests *Transaction requests* represents the total number of transactions sent by wallets associated with the project. <img src="https://content.gitbook.com/content/neke8a6D4Ybg9dkRA2GD/blobs/w3Doda3FkeBndF0yu0sk/image%20(2).png" alt="" data-size="original"> </details> <details> <summary>Indexer</summary> Sequence Indexer - offered via the Xai Builder - is a simple API to query any blockchain token and NFT data. Simply select the data you want from the indexer, and it generates the necessary code in snippets Fetch different kinds of data from the indexer: * tokens and collectibles owned by any wallet * total supply for any token or collectible * the transaction and transfer history for any wallet address * contract metadata for any token or collection * metadata for any collectible * balance change events for any token or collection Click [here](https://docs.sequence.xyz/solutions/builder/indexer) to get started with the indexer from Xai Builder and see it in action. ### Webhooks #### No-Code Webhooks Xai Builder equips game builders with an indexer that listens to events across the many blockchains that is powered by Sequence to provide an HTTPS callback to a URL you specify - this means you can listen on that endpoint and get up to date information on what’s happening on-chain, customized for what you want to listen to. #### What data can I listen to for my game? * Mints from a contract * TokenID transfers * Transactions by an account address * Event topics, topic hashes, and events emitted by a contract To create Webhooks for your game, simply click [here](https://docs.sequence.xyz/solutions/builder/webhooks/#select-project-and-go-to-webhooks-section) to get started. </details> <details> <summary>Marketplaces</summary> #### Whitelabel Marketplaces Xai Builder provides game builders with a white-label marketplace that can be launched in seconds. With Xai Builder, you can customize your marketplace and integrate it directly into your game experience, all with no-coding experience necessary. #### Try it out Get started quickly at [Xai Builder](https://builder.xai.games/) to launch your marketplace. #### Why would I want my own Marketplace for my web3 game? Xai Builder gives you full control over everything in your marketplace, from enforcing royalties (with ERC-2981) to choosing the best trading mechanism for your community, setting fees, and more. You can also aggregate listings from major platforms like OpenSea or LooksRare, providing you with the benefit of existing liquidity without relinquishing control of the gaming experience. ### Custom Marketplace The Sequence Marketplace API service offers a simple and fast way to interact with sequence marketplace protocols to build a custom marketplace while accelerating your development time. The API is designed to be easy to use and to 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. # Getting Started ## What is Xai Vanguard: Genesis? Welcome to the next evolution of the Xai Games community. Xai Vanguard: Genesis is the beginning of your odyssey across the Xai Gaming ecosystem. On this journey you can take part in the launch of over 10 new games on Xai, interact with cutting-edge web3 technologies, become a builder, creator, or ambassador—the choice is yours. Claim your place among the Xai community, help shape the future of Xai, and earn the distinction of Xai Vanguard.&#x20; Each chapter of Xai Vanguard: Genesis will spotlight a new piece of the growing Xai Gaming ecosystem. As you complete quests across these chapters, you will accumulate points on the Genesis leaderboard, tracking your contribution to the Xai community. Esteemed contributors can earn Legendary and Vanguard status, with special roles for gamers, ambassadors, and builders–unlocking access to unique opportunities and recognition in the Xai community.&#x20; Here’s what you can expect with Xai Vanguard: Genesis&#x20; * Introduction - June: Join us for Xai Ecosystem month, featuring our partners and an array of dApps deployed across Xai. Quests will cover on-chain engagement, community involvement, and getting to know the growing Xai ecosystem. * Game Stage - July through November: We will spotlight a lineup of games deploying to Xai, with points to score for completing in-game quests and connecting with the games’ communities. There are an array of groundbreaking games on the way, with many ways to connect and become a part of the growing community of Xai gamers. We are nothing without our community. Xai Vanguard: Genesis is the beginning of something big and we’re thrilled to have you aboard. As we grow, we’d like to take you with us and usher in the era of Web3 gaming together. The journey promises to be exhilarating, enriching, and undeniably worthwhile. ## Get Ready Before you can participate in Xai Vanguard: Genesis, you will need to connect your wallet to Xai - see how-to guide [**here**](/xai-network/kn/play-games-on-xai/connect-your-wallet-to-xai). ## Get Set To participate in Xai Vanguard: Genesis, you will need to complete quests on Galxe which can be found here: <https://app.galxe.com/quest/xaigames/GCzuatdz2R>. New chapters containing quests will become available each day so check back early and often. The more quests you complete, the higher you will reach the leaderboard. Here's how to get everything set up: 1. Go to <https://app.galxe.com/quest/xaigames/GCzuatdz2R>. 2. Log in using your web3 wallet (Metamask is recommended). {% hint style="info" %} If you do not have a Metamask wallet, you can create one here: <https://metamask.io/>. Then follow [these steps](/xai-network/kn/play-games-on-xai/connect-your-wallet-to-xai) to connect to Xai Mainnet. {% end
프로젝트로 돌아가기