# JavaScript Libraries Source: https://docs.qu.ai/build/apis/javascript-libraries An overview of the JavaScript APIs available for interacting with Quai Network. ## Overview Every application built on top of Quai Network requires a connection to the network in order to interact with smart contracts, send transactions, or sign messages on behalf of a user. Using the direct client JSON-RPC API is possible, but the methods can be quite verbose for use in application interfaces. JavaScript APIs and SDKs offer a simplified interface for web applications to interact with Quai Network via one-line methods, conversion utils, and smart contract wrappers. The available libraries can be found below. ### quais.js A complete Quai Network interaction library for JavaScript and TypeScript. ## Library Features ### Connect to Quai Nodes Abstract providers make it easy to connect to, read data from, and broadcast transactions to Quai Network nodes. Providers are composable, so you can connect to remote endpoints, local nodes, or even custom infrastructure. Providers can query **any zone chain** in the network for: * Block data * Transaction data and gas estimates * Account balances * Smart contract data * And more... ```javascript theme={null} // Connect to a remote node const provider = new quais.JsonRpcProvider('https://rpc.quai.network', undefined, { usePathing: true }) // Connect to an injected provider (e.g. Pelagus) const provider = new quais.BrowserProvider(window.pelagus) ``` ### Smart Contract Functionality Libraries like Quais.js provide smart contract wrappers that make it easy to call smart contract functions, return event data, and read state variables. Smart contract wrappers serve as JavaScript interpreters for contract ABIs, allowing you to call functions and read data from smart contracts without having to interface with Solidity directly. Smart contract wrappers also provide a number of useful features, including: * Transaction simulation * Raw transaction generation * Event filtering ```javascript theme={null} // set up a contract interface const contract = new quais.Contract(contractAddress, contractABI, provider) // call a contract function const result = await contract.setGreeting('Hello, world!') // read a contract state variable const greeting = await contract.staticCallResult.greet() ``` ### Utilities Quais.js ships with a number of small but powerful utilities that make working with Quai Network simple. They provide useful shortcuts for converting units, getting shard information, and formatting data. Other useful utilities include: * Unit conversion and parsing * Data encoding and formatting * Address validation ```javascript theme={null} // get zone name from an address const shard = quais.getZoneFromAddress('0xa844d9a88331e9688d3065f92c11e25ab1e50aa6') // parse units to BigNumber const quai = quais.parseQuai('1') // base58 encode a string const decoded = quais.decodeBase58('MergedMining') ``` # Variables Source: https://docs.qu.ai/build/apis/postman/environment How to configure and use environment variables in Postman for the Quai Network API. ## Introduction Postman supports a number of different variable "scopes": * **Global** * **Collection** * **Environment** * **Data** * **Local** In this guide, we'll focus on **Environment Variables**. Environment variables are a way to store and reuse values across multiple requests in a collection, which can be particularly useful in our case for storing RPC endpoint URLs, addresses, and other values that are shared across multiple go-quai API requests. ## Environment Variables The Example Quai Postman Environment includes a small number of pre-defined environment variables that you can use in your requests. These variables include: * `chain` * `myAddress` * `txHash` * `blockNumber` This guide assumes you have already installed Postman and imported the [Example Quai Postman Environment](https://github.com/dominant-strategies/quai-postman-collection). If you have not done so, please refer to the [Setting Up Postman](/build/apis/postman/setup) guide. The pre-configured environment variables can be accessed via the `Environment` tab in the top left of the Postman application: To add your own environment variable, simply type your variable name in the `Add new variable` field at the bottom of the list and fill it in with the desired value. ## Chain Specific Variables Quai Network has [many distinct chains](/build/networks/#testnet), each with their own [sharded address space](/learn/advanced-introduction/hierarchical-structure/sharding), state, and unique data. To send a request to a specific chain, you must define the `chain` environment variable with the chain name you want to interact with and ensure that all of the arguments you pass to the request are valid for that chain. For example, to request balance data for my address on Cyprus 1, I need to: * set the `chain` environment variable to `cyprus1` to route to the Cyprus 1 RPC endpoint * ensure that the `myAddress` parameter in the request is a valid Cyprus 1 address If the data passed to the request is not valid on the specified chain, **the request will return an error**. ## Usage Environment variables can be used in any request by wrapping the variable name in double curly braces (`{{}}`). For example, **all Quai Postman Collection requests** use a `{{chain}}` variable to specify the chain to request data from in the RPC endpoint URL: ``` https://rpc.{{chain}}.colosseum.quaiscan.io ``` The `{{ chain }}` variable is the only environment variable used by default in all requests. All other variables are optional and can be used as needed. The same principle applies to any other defined environment variable. For example, if you define the `{{txHash}}` variable with your own transaction hash, you can use it in a request like this: ```json theme={null} { "jsonrpc": "2.0", "method": "quai_getTransactionByHash", "params": [ {{txHash}} ], "id": 1 } ``` When the request is sent, Postman will automatically replace `{{chain}}` with the value of the `chain` environment variable. You can hover over the `{{}}` to see the resolved value: # Setting Up Postman Source: https://docs.qu.ai/build/apis/postman/setup How to set up Postman for use with the Quai Network API. Our team has created a [Postman collection for Quai Network](https://docs.api.qu.ai/), which includes all of the publicly available API calls for go-quai bundled with documentation, examples, and environment variables. Postman provides a user-friendly interface for making API requests to a go-quai node without having to deal with long `curl` commands or JSON-RPC payloads. A JSON formatted version of the Quai Postman collection can be found in the [`quai-postman-collection` repository](https://github.com/dominant-strategies/quai-postman-collection). ## Introduction to Postman Postman is a popular API client that makes it easy to send requests, test endpoints, and share collections of methods through a unified and scalable interface. Postman is available as both a **desktop application** and **web application** available on Linux, MacOS, and Windows. *The desktop application is the most feature-rich and is recommended for most users*. The Quai Postman collection ships with a full library of API request templates and commonly used environment variables so you don't have to constantly re-write requests or variable definitions. Using the Quai Postman collection, you can interact with any Quai Network client *with minimal code and configuration*. ## Configuration As mentioned above, Postman is available as both a desktop application and web application. While the web application is convenient for quick access, **we recommend using the desktop application** for access to all features and better performance. To download the Postman desktop application, visit the [Postman website](https://www.postman.com/downloads/) and download the version for your operating system. Once downloaded, it is recommended that you sign up with an email address to save and sync your collections across devices and platforms. Postman supports raw collection imports from a URL or a local file. To import the Quai Postman collection, click the `Import` button in the top left corner of the Postman application: This will open the import options modal: To import the Quai Postman collection, paste the following URL into the `Paste cURL, Raw Text, or URL...` field: ``` https://raw.githubusercontent.com/dominant-strategies/quai-postman-collection/main/go-quai.postman_collection.json ``` Once the import has completed, you'll see the **Quai Postman Collection** in the left sidebar of the Postman application: Now that we have the Quai Postman collection imported, we need to import the environment variables. To import the Quai Postman environment variables, click the `Import` button in the top left corner of Postman like before, but this time, **paste the URL to the environment variables file**: ``` https://raw.githubusercontent.com/dominant-strategies/quai-postman-collection/main/example-quai-environment.postman_environment.json ``` Postman will automatically recognize the format of the environment variables file. When the import is complete, you should see this modal in the left right corner of the Postman application: Lastly, you'll need to select the `Example Quai Postman Environment` from the dropdown in the top right corner of the Postman application: Your environment variables are now **set as the active environment** and ready to use. When set as the active environment, the Quai Postman collection will be correctly configured with RPC endpoints, addresses, and hashes! ## Conclusion Now that you've installed Postman, imported the Quai API collection, and configured environment variables, **you're ready to start making requests to a go-quai node**. *Further documentation and tutorials* on how to use the Quai Postman collection can be found below: **Quai Postman Guides** * [Environment Variables Guide](/build/api/postman/environment) * [Making Requests Guide](/build/api/postman/use) **API Specification** * Pre-packaged specs and examples inside of the Quai Postman Collection * [Quai Postman Collection Documentation](https://docs.api.qu.ai/) * [JSON-RPC API Documentation](/build/playground/overview) # Making Requests Source: https://docs.qu.ai/build/apis/postman/use How to make API requests to Quai Network using Postman. This guide assumes you have already installed [Postman](https://www.postman.com/downloads/) and imported the [Quai Postman Collection](/build/apis/postman/setup) and [Example Quai Postman Environment](/build/apis/postman/variables). ## Introduction Making requests to a go-quai client via the Quai Postman collection is straightforward. The basic steps to making a request are: Select a request from the Quai Postman collection Ensure the URL in the request is correct for the chain you want to interact with (e.g. cyprus1 endpoint for cyprus 1 queries) Edit the request body with the desired parameters (e.g. address, block number, etc.) Click the `Send` button to make the request View the response in the section below the request body ## Making Your First Request To make your first request to a go-quai client, open the Quai Postman Collection in the left sidebar of Postman and select a request from the collection. For example, let's select the `getBalance` request under the `quai` folder: Once you've selected `getBalance`, you'll be directed to the `Params` tab for the request. To edit the parameters for the request, choose the `Body` tab to see the JSON-RPC request body: ```JSON theme={null} { "jsonrpc": "2.0", "method": "quai_getBalance", "params": [ "0x0255b093f1c3c54d2d56af9909a9b8e6466f1926", // can replace with {{myAddress}} "latest" ], "id": 1 } ``` To request the balance of a specific address, replace the placeholder address `0x0255b093f1c3c54d2d56af9909a9b8e6466f1926` with the address you'd like to query. You can also use the `{{myAddress}}` environment variable to reference your own address *if you've configured it in the environments tab on the left*. More information on how to configure environment variables like `{{ myAddress }}` can be found in the [Environment Variables Guide](/build/apis/postman/environment). Once you've updated the request body with the desired address, click the `Send` button to make the request. The response will be displayed in the response section below the request body: ```JSON theme={null} { "jsonrpc": "2.0", "id": 1, "result": "0x0" } ``` ## Common Mistakes ### Chain and Data Mismatch Often times sending a request using the Quai Postman Collection can result in one of the following errors: `address is not in scope` or `genesis is not traceable`. If this is the case, it's likely that the params you are passing to the method call do not correspond with the RPC endpoint you are querying. Ensure that the `chain` environment variable (or manually set request URL) is set to the correct chain you are querying data from. **Example**: * Querying the URL: `https://rpc.cyprus1.quaiscan.io` with a `getBalance` request for an address that only exists on `hydra3`: `0xfbca7e03dc8b5c4cc327c92de8ba1af66d34ac70`. ### Non-Existent Data When sending requests related to blocks or transactions, often times the node will return an error related to `method handler crashed` or `no data found`. This is often due to the block or transaction hash not existing on the chain you are sending the request to. Ensure that the block number or transaction hash you are providing exists on the canonical chain you are querying. **Example:** * Requesting block data for block 10000 when the chain you are querying only has 5000 blocks. ## Conclusion Now that you've made your first request to a go-quai client using the Quai Postman Collection, you're ready to start exploring the full range of API requests available in the collection. For specifications on available methods and parameters, refer to the [Quai JSON-RPC API documentation](/build/playground/overview) or the [Quai Postman Collection](https://docs.api.qu.ai/). # Quai Builders Program & Grants Source: https://docs.qu.ai/build/grants Get started building on Quai Network today! The Quai Builders Program seeks innovative projects that harness the network's distinctive features, including its dual-token architecture, PoEM consensus mechanism, and vision for a decentralized energy-based currency. **Quai Team Contact:** Email: [bd@quai.org](mailto:bd@quai.org) ## Vision and Framework We welcome proposals across a wide spectrum of project categories that leverage Quai Network's unique capabilities. ### 1. Quai Public Goods Infrastructure protocols and development tools that enhance the foundation for all applications built on Quai Network. We're seeking projects that improve developer experience, user interactions, and overall ecosystem functionality. ### 2. Cross-Chain Infrastructure Bridging services and pricing oracles that allow the Quai Network users to bring their liquidity from their other homes into ours and also allow trading to occur cross-chain. ### 3. DeFi Protocols Advanced borrowing and lending protocols that strengthen Quai Network's financial infrastructure. We're looking for innovative DeFi applications that leverage Quai's unique features and expand the network's capabilities. ### 4. Novel Applications Groundbreaking dApps that push the boundaries of what's possible on Quai Network. We welcome visionary builders with compelling ideas that demonstrate technical excellence and real-world utility. ## Evaluation Criteria Projects submitted to the Quai Builders Program will be evaluated based on the following criteria: Number of active wallets, transaction volume, user growth rate, community engagement metrics, and social media presence. Demonstrated working product, publicly available code, smart contract security measures, and technical innovation utilizing Quai's features. Track record in crypto/blockchain development, previous successful project launches, and commitment to the project. Partnership development, media coverage and industry recognition, marketing strategy and execution, and community building efforts. ## Illustrative Project Ideas Looking for inspiration? Here are some project ideas that could make a significant impact on the Quai ecosystem: A comprehensive analytics suite for Quai/Qi token metrics and network health. An innovative DeFi product leveraging Quai's unique mining reward system. A seamless payment gateway integrating Qi with conventional financial systems or a turnkey solution for e-commerce platforms to accept Qi payments. A robust cross-chain bridge connecting Quai to other major networks. An in-depth economic analysis of Quai and Qi's roles in the broader crypto landscape or a sophisticated model for predicting Qi mining profitability. Educational content highlighting Quai's advantages as an energy-based currency. ## Grant Program Overview
10M \$QUAI
Total Program Allocation
Projects can receive up to **1M \$QUAI** per grant based on: * Quality of application submission * Potential reach to new users * Impact on ecosystem growth * **Note** restrictions on the use of funds may apply, such as vesting periods or specific milestones ## How to Apply Follow these steps to submit your application to the Quai Builders Program: Launch your application on Quai mainnet. Create a Questbook account. Go to the dashboard of the "Quai Grants". Click on the "Submit New" button on the top left of the page. Fill the form with all the data requested. Use the [application template](https://docs.google.com/document/d/1QILbW9Bp_jM8pDoKv_nkSN8cFJ2zMvIQ5MpGuKVwDXY/edit?usp=sharing) to fill in the "details" section. If your grant application is considered, team members will be in touch directly. Submit your application on Questbook # Development Introduction Source: https://docs.qu.ai/build/introduction Learn the basics of developing on Quai. The main differences between Quai’s EVM and the traditional EVM can be seen below. Each zone chain contains a [unique set of Quai and Qi addresses](/learn/advanced-introduction/hierarchical-structure/sharding) based on each address's prefix. The prefix denotes which shard and ledger the address belongs to. The [Go-Quai client API](/build/playground/introduction) closely resembles that of Ethereum, but uses the `quai_` namespace rather than the `eth_` namespace. The API also contains many of, but not all, the same methods. Quai’s EVM handles traditional [Solidity](/build/smart-contracts/solidity) smart contracts. Both Ethereum and [Quai-specific tooling](#available-tooling) can be used to build on Quai Network. Read more in [Migrating your Ethereum App to Quai](#migrating-your-ethereum-app-to-quai). Quai utilizes additional [new transaction types](/learn/advanced-introduction/hierarchical-structure/sharding) compared to the typical EVM to handle cross-chain and UTXO transactions. ## Available Tooling As mentioned earlier, Quai has a subset of Ethereum tooling that has been adapted to handle the multi-chain network. This tooling includes: The community built wallet for Quai with support for both Quai and Qi environments. A modified version of the Hardhat framework built for Quai Network. A complete Quai Network interaction library for JavaScript and TypeScript. A containerized, feature complete local node environment for Quai. The central source for testnet Quai token drips. Track transactions and blocks on the testnet. ## Migrating your Ethereum App to Quai Ethereum applications are typically built with some combination of Ethers, Web3.js, Viem, and WAGMI. These tools work out of the box for web based dapp development *as long as* you are using Pelagus wallet as an injected provider. If you are using a different wallet or not building a web based dapp, you can still use these tools for querying chain data, however, you will need to incorporate or transition to the [Quais SDK](https://www.npmjs.com/package/quais) for sending transactions. The Quais SDK is a fork of [Ethers v6](https://docs.ethers.org/v6/). Because of this, syntax in Quais is nealy identical to Ethers with the caveat that the above changes have been applied. If your application is currently built with Viem or Web3.js, these guides are helpful in understanding syntax mapping of your existing code to Quais: * [**Viem to Ethers Guide**](https://viem.sh/docs/ethers-migration) * [**Web3.js to Ethers Guide**](https://docs.ethers.org/v5/migration/web3/) Almost all of the existing functions and utilities in Ethers, Viem, and Web3.js have direct mappings to similar or the same methods in Quais.js, with the exception of methods that utilize provider polling. # Networks Source: https://docs.qu.ai/build/networks Specifications for Quai Network and its testing environments. ## Quai Mainnet The Quai Mainnet serves as the production environment for Quai Network. This network can be used by all to interact with tokens Quai and Qi. The Quai Mainnet is currently live and running the latest version of [go-quai](guides/client/node). Developers looking to test can use the Orchard Testnet. ### Network Specifications 9 23621466532946281564673705261963422 [https://stats.quai.network](https://stats.quai.network) [https://quaiscan.io](https://quaiscan.io) #### RPC Endpoints Cyprus-1 is the only active zone in Quai Network as of now. | Zone Name | Zone Index | RPC Endpoint (https) | RPC Endpoint (wss) | GraphQL Endpoint | | --------- | ---------- | -------------------------------------------------------------------- | ------------------------------- | -------------------------------------------------------- | | cyprus | \[0 0] | [https://rpc.quai.network/cyprus1](https://rpc.quai.network/cyprus1) | wss\://rpc.quai.network/cyprus1 | [https://graph.quai.network](https://graph.quai.network) | ## Orchard Testnet This network is for development purposes only. Quai tokens on this network have no real value. Orchard Testnet is a public isolated development environment that is designed to be used by both smart contract and tooling developers to test smart-contract deployments and infrastructure upgrades in a production-like environment. QUAI on this testnet has no real value and thus testing deployments, interactions, and smart contracts are virtually free. As Orchard Testnet QUAI has no value, there are *no markets* to purchase devnet tokens. ### Network Specifications 15000 62242624366553750196964614682162313 [https://orchard.faucet.quai.network](https://orchard.faucet.quai.network) [https://orchard.quaiscan.io](https://orchard.quaiscan.io) #### RPC Endpoints | Zone Name | Zone Index | RPC Endpoint (https) | RPC Endpoint (wss) | GraphQL Endpoint | | --------- | ---------- | ------------------------------------------------------------------------------------ | --------------------------------------- | ------------------------------------------------------------------------ | | cyprus | \[0 0] | [https://orchard.rpc.quai.network/cyprus1](https://orchard.rpc.quai.network/cyprus1) | wss\://orchard.rpc.quai.network/cyprus1 | [https://orchard.graph.quai.network](https://orchard.graph.quai.network) | ## Local Network A local instance of Quai Network is an isolated development environment that can be spun up on a single machine. This private network offers faster block times, lower block difficulties with the full range of Quai Network capabilities. Using a local network allows developers looking to launch applications to work faster and with better privacy than on a public testnet. They also provide the ability to easily control a network environment and develop privately. You can easily spin up a pre-configured development environment using the [Local Node Runner](/guides/client/local-node) and [Docker compose](https://docs.docker.com/compose/). The Local Node Runner spins up a containerized local Quai environment complete with multiple shards, CPU miner, and accounts pre-loaded with Quai and Qi tokens. ### Network Specifications 1337 ### Networking Information Do not publically expose these HTTP ports for any reason. You will be putting your local network security at risk. | Chain Name | Chain Index | HTTP Port | WS Port | | ---------- | ----------- | --------- | ------- | | Prime | | 9000 | 8000 | | Cyprus | | 9001 | 8001 | | Paxos | | 9002 | 8002 | | Hydra | | 9003 | 8003 | | Cyprus1 | \[0 0] | 9200 | 8200 | | Cyprus2 | \[0 1] | 9201 | 8201 | | Cyprus3 | \[0 2] | 9202 | 8202 | | Paxos1 | \[1 0] | 9220 | 8220 | | Paxos2 | \[1 1] | 9221 | 8221 | | Paxos3 | \[1 2] | 9222 | 8222 | | Hydra1 | \[2 0] | 9240 | 8240 | | Hydra2 | \[2 1] | 9241 | 8241 | | Hydra3 | \[2 2] | 9242 | 8242 | ## Golden Age Testnet This network has concluded as of January 2025. Data from this network is archived and only being used for the claims process. # getBalance Source: https://docs.qu.ai/build/playground/addresses/getBalance openapi-getBalance POST / Returns the balance of the specified address. # getCode Source: https://docs.qu.ai/build/playground/addresses/getCode openapi-getCode POST / Returns the code stored at a given address. # getOutpointsByAddressAndRange Source: https://docs.qu.ai/build/playground/addresses/getOutpointsByAddressAndRange openapi-getOutpointsByAddressAndRange POST / Returns the outpoints for a given address and block range. # getProof Source: https://docs.qu.ai/build/playground/addresses/getProof openapi-getProof POST / Returns the Merkle-Proof for a given account and optional storage keys. # getStorageAt Source: https://docs.qu.ai/build/playground/addresses/getStorageAt openapi-getStorageAt POST / Returns the value from a storage position at a given address. # getTransactionCount Source: https://docs.qu.ai/build/playground/addresses/getTransactionCount openapi-getTransactionCount POST / Returns the total transaction count for a given address. # blockNumber Source: https://docs.qu.ai/build/playground/blocks/blockNumber openapi-blockNumber POST / Returns the current block number. # getBlockByHash Source: https://docs.qu.ai/build/playground/blocks/getBlockByHash openapi-getBlockByHash POST / Returns block data for a given block hash. # getBlockByNumber Source: https://docs.qu.ai/build/playground/blocks/getBlockByNumber openapi-getBlockByNumber POST / Returns block data for a given block number. # getBlockOrCandidateByHash Source: https://docs.qu.ai/build/playground/blocks/getBlockOrCandidateByHash openapi-getBlockOrCandidateByHash POST / Returns block or candidate block data for a given hash. # getHeaderByHash Source: https://docs.qu.ai/build/playground/blocks/getHeaderByHash openapi-getHeaderByHash POST / Returns the header for a given block hash. # getHeaderByNumber Source: https://docs.qu.ai/build/playground/blocks/getHeaderByNumber openapi-getHeaderByNumber POST / Returns the header for a given block number. # getHeaderhashByNumber Source: https://docs.qu.ai/build/playground/blocks/getHeaderHashByNumber openapi-getHeaderHashByNumber POST / Returns the hash of the block header for a specific block number. # getPendingHeader Source: https://docs.qu.ai/build/playground/blocks/getPendingHeader openapi-getPendingHeader POST / Returns the current pending block header. # uncleByHashAndIndex Source: https://docs.qu.ai/build/playground/blocks/getUncleByBlockHashAndIndex openapi-getUncleByBlockHashAndIndex POST / Returns the uncle block for a given block hash and index. # uncleByNumberAndIndex Source: https://docs.qu.ai/build/playground/blocks/getUncleByBlockNumberAndIndex openapi-getUncleByBlockNumberAndIndex POST / Returns the uncle block for a given block number and index. # uncleCountByHash Source: https://docs.qu.ai/build/playground/blocks/getUncleCountByBlockHash openapi-getUncleCountByBlockHash POST / Returns the uncle count for a given block hash. # uncleCountByNumber Source: https://docs.qu.ai/build/playground/blocks/getUncleCountByBlockNumber openapi-getUncleCountByBlockNumber POST / Returns the uncle count for a given block number. # calculateConversionAmount Source: https://docs.qu.ai/build/playground/conversion/calculateConversionAmount openapi-calculateConversionAmount POST / Returns the amount of Quai in Wei or Qi in Qits left after converting an amount of Qi in Qits to Quai in Wei at the current block exchange rate and after applying the appropriate slip. # qiToQuai Source: https://docs.qu.ai/build/playground/conversion/qiToQuai openapi-qiToQuai POST / Returns the rate for converting an amount of Qi in Qits to Quai in Wei at a specific block. # quaiToQi Source: https://docs.qu.ai/build/playground/conversion/quaiToQi openapi-quaiToQi POST / Returns the rate for converting an amount of Quai in Wei to Qi in Qits at a specific block. # getBlockRlp Source: https://docs.qu.ai/build/playground/debug/getBlockRlp openapi-getBlockRlp POST / Returns the RLP encoded block given its number. # printBlock Source: https://docs.qu.ai/build/playground/debug/printBlock openapi-printBlock POST / Returns raw data for a block given its number. # traceTransaction Source: https://docs.qu.ai/build/playground/debug/traceTransaction openapi-traceTransaction POST / Returns the raw trace for a transaction. # estimateGas Source: https://docs.qu.ai/build/playground/gas-and-fee/estimateGas openapi-estimateGas POST / Estimates the gas required to execute the given transaction # feeHistory Source: https://docs.qu.ai/build/playground/gas-and-fee/feeHistory openapi-feeHistory POST / Returns the feeHistory for a given a block range. # gasPrice Source: https://docs.qu.ai/build/playground/gas-and-fee/gasPrice openapi-gasPrice POST / Returns the current gas price. # setLockupByte Source: https://docs.qu.ai/build/playground/miner/setLockupByte openapi-setLockupByte POST / Changes the coinbase lockup duration for the miner. # setMinerPreference Source: https://docs.qu.ai/build/playground/miner/setMinerPreference openapi-setMinerPreference POST / Changes the Quai/Qi block reward preference for the miner. # listening Source: https://docs.qu.ai/build/playground/net/listening openapi-listening POST / Returns an indicator of whether client is listening for network connections. # peerCount Source: https://docs.qu.ai/build/playground/net/peerCount openapi-peerCount POST / Returns the number of peers currently connected to the client. # version Source: https://docs.qu.ai/build/playground/net/version openapi-version POST / Returns the devp2p network ID. # chainId Source: https://docs.qu.ai/build/playground/other/chainId openapi-chainId POST / Returns the current chain ID. # getProtocolExpansionNumber Source: https://docs.qu.ai/build/playground/other/getProtocolExpansionNumber openapi-getProtocolExpansionNumber POST / Returns the number of dynamic chain expansions that have occurred since the genesis block. # listRunningChains Source: https://docs.qu.ai/build/playground/other/listRunningChains openapi-listRunningChains POST / Returns an array representation of the currently running chains sorted by shard index. # nodeLocation Source: https://docs.qu.ai/build/playground/other/nodeLocation openapi-nodeLocation POST / Returns the current node location or context # JSON-RPC Overview Source: https://docs.qu.ai/build/playground/overview Technical specification of Quai Network JSON-RPC API methods and usage. ## Convenience Libraries While some developers may opt to interact directly with the JSON-RPC API directly, there are also a number of available convenience libraries designed to make data interaction much easier. Convenience libraries abstract much of the complexity of direct client API calls out into simple one-line methods. | | | | ----------------------------------------------- | -------------------------------------------------------------------------------- | | [Quais SDK](/sdk/introduction) | A complete Quai Network interaction library for JavaScript and TypeScript. | | [Quai Postman Collection](/build/apis/postman/) | A collection of API requests for Quai Network that can be imported into Postman. | ## Method Groups ## Conventions ### Local Chain Data Each zone chain within Quai Network maintains a unique, local set of data. Each address, contract, and transaction made on the network "lives" in a specific zone chain, or a [sharded state](/learn/advanced-introduction/hierarchical-structure/sharding). A general understanding of this concept is required to effectively use the JSON RPC API to query data and interact with the network. To query data for a specific address, contract, or transaction, you must send your JSON RPC request to the corresponding zone chain. Each zone chain has a unique RPC endpoint URL or port number to communicate with. For example, the RPC endpoint URL for the Cyprus 1 zone chain is `https://rpc.quai.network/cyprus1`, to which you can query data for all Cyprus 1 addresses, contracts, and more. If you attempt to query a node for data that does not exist on the chain you are requesting to (*i.e. requesting a Paxos 1 node for Cyprus 1 address data*), the request will return an error. ### Protobuf Encoding Quai Network's transaction encoding format has been transitioned from RLP (Recursive Length Prefix) to Protobuf (Protocol Buffers). Protobuf is a language-neutral, platform-neutral, extensible mechanism for serializing structured data, developed by Google. It offers several advantages over RLP, including more efficient serialization, easier backward and forward compatibility, and better support for complex data structures. This transition **only affects JSON RPC API methods related to sending transactions**. All other methods are unaffected by this change. This allows for ensuring a more robust and streamlined process for sending and signing transactions. The process for composing, signing, and sending a transaction with Protobuf encoding is as follows: Compose the unsigned transaction in JSON format Encode the unsigned transaction in Protobuf Sign the encoded transaction Add the signature to the unsigned transaction and encode using Protobuf Send the encoded signed transaction ### Hexadecimal Encoding When making calls to a node, data can be passed or returned in two types via JSON. These types are quantities and unformatted byte arrays. Both utilize hex encoding for compact representation but have slightly different formatting requirements. #### Quantities When encoding quantities like numbers and integers, use the following format: * Encode as a hexadecimal * Prefix all data with "0x" *Example*: 21000 in decimal is "0x5208" #### Unformatted Data To encode unformatted data such as addresses, byte arrays, hashes, etc. - use the following format: * Encode as a hexadecimal * Prefix with "0x" * Two hex digits per byte of data, with an even number of digits only *Example*: "Hello" is encoded as "0x48656C6C6F" ### Default Block Parameter The default block parameter is an extra parameter that can be passed when querying the state of Quai Network. This parameter allows you to specify a specific block or state of Quai that you would like to receive data from. When not passed in a call, this parameter defaults to the height of the most recent block. Available options for this parameter are: | Option | Description | | ---------------- | ----------------------------- | | `earliest` | Genesis block | | `latest` | Most recently mined block | | `pending` | Pending state changes | | **Block Number** | Block number to query data at | The default block parameter can be passed to the following methods: # call Source: https://docs.qu.ai/build/playground/transactions/call openapi-call POST / Executes a new message call without creating a transaction on chain. # createAccessList Source: https://docs.qu.ai/build/playground/transactions/createAccessList openapi-createAccessList POST / Creates an access list for the provided transaction. # blockTxCountByHash Source: https://docs.qu.ai/build/playground/transactions/getBlockTransactionCountByHash openapi-getBlockTransactionCountByHash POST / Returns the transaction count for a block given its hash. # blockTxCountByNumber Source: https://docs.qu.ai/build/playground/transactions/getBlockTransactionCountByNumber openapi-getBlockTransactionCountByNumber POST / Returns the transaction count for a block given its number. # rawTxByHashAndIndex Source: https://docs.qu.ai/build/playground/transactions/getRawTransactionByBlockHashAndIndex openapi-getRawTransactionByBlockHashAndIndex POST / Returns the bytecode for a raw transaction given block hash andtransaction index. # rawTxByNumberAndIndex Source: https://docs.qu.ai/build/playground/transactions/getRawTransactionByBlockNumberAndIndex openapi-getRawTransactionByBlockNumberAndIndex POST / Returns bytecode for a raw transaction given block number and transaction index. # rawTxByHash Source: https://docs.qu.ai/build/playground/transactions/getRawTransactionByHash openapi-getRawTransactionByHash POST / Returns the bytecode for a raw transaction given its hash. # txByBlockHashAndIndex Source: https://docs.qu.ai/build/playground/transactions/getTransactionByBlockHashAndIndex openapi-getTransactionByBlockHashAndIndex POST / Returns transaction data given block hash and the transaction index. # txByBlockAndIndex Source: https://docs.qu.ai/build/playground/transactions/getTransactionByBlockNumberAndIndex openapi-getTransactionByBlockNumberAndIndex POST / Returns transaction data given a block number and the transaction index. # getTransactionByHash Source: https://docs.qu.ai/build/playground/transactions/getTransactionByHash openapi-getTransactionByHash POST / Returns a transaction and its data for a given transaction hash. # getTransactionReceipt Source: https://docs.qu.ai/build/playground/transactions/getTransactionReceipt openapi-getTransactionReceipt POST / Returns the receipt of a transaction by transaction hash. # sendRawTransaction Source: https://docs.qu.ai/build/playground/transactions/sendRawTransaction openapi-sendRawTransaction POST / Creates new message call, transaction, or contract creation for signed transactions. # content Source: https://docs.qu.ai/build/playground/txpool/content openapi-content POST / Returns the current content of the transaction pool. # contentFrom Source: https://docs.qu.ai/build/playground/txpool/contentFrom openapi-contentFrom POST / Returns transactions in the txpool from the given address. # inspect Source: https://docs.qu.ai/build/playground/txpool/inspect openapi-inspect POST / Returns a summarized form of the transaction pool content. # status Source: https://docs.qu.ai/build/playground/txpool/status openapi-status POST / Returns the current size of the transaction pool. # Quick Links Source: https://docs.qu.ai/build/quick-links Tools and resources for developing on Quai Network. ## Mainnet Infrastructure | | | | ------------------------------------------------------ | ----------------------------------------------------------------------------- | | [Quaiscan Explorer](https://quaiscan.io/) | The public explorer for Quai Network mainnet. | | [Quaiscan Documentation](https://docs.quaiscan.io/) | Documentation for Quaiscan usage, APIs, and more. | | [Network Statistics Page](https://stats.quai.network/) | Mainnet statistics dashboard. | | [GraphQL Endpoint](https://graph.quai.network/) | Mainnet GraphQL endpoint for querying chain data with filters and pagination. | ## Testnet Infrastructure | | | | ------------------------------------------------------- | ------------------------------------------------------------------- | | [Quaiscan Explorer](https://orchard.quaiscan.io/) | The public explorer for Orchard Testnet. | | [Quaiscan Documentation](https://docs.quaiscan.io/) | Documentation for Quaiscan usage, APIs, and more. | | [Faucet](https://orchard.faucet.quai.network/) | The central source for testnet Quai token drips on Orchard Testnet. | | [GraphQL Endpoint](https://orchard.graph.quai.network/) | Orchard Testnet GraphQL endpoint for querying chain data. | ## Tooling | | | | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | | [API Playground](/build/playground/overview) | Playground for interacting with the go-quai JSON-RPC API. | | [Local Network Runner](/guides/client/local-node) | A containerized Quai Network instance built for local development. | | [Quais SDK](/sdk/introduction.mdx) | A JavaScript/TypeScript library built for interacting with Quai Network. | | [Quais SDK npm package](https://www.npmjs.com/package/quais) | The Quais SDK npm package. | | [Quais + Hardhat](https://github.com/dominant-strategies/hardhat-example/tree/main/Solidity) | Example usage of the Quais SDK with Hardhat. | ## Wallets | | | | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | | [Pelagus Website](https://pelaguswallet.io/) | The primary wallet for interacting with Quai Network. | | [Pelagus Extension](https://chromewebstore.google.com/detail/pelagus/nhccebmfjcbhghphpclcfdkkekheegop) | The most current Pelagus Wallet extension download. | | [Pelagus Extension (Iron Age Version)](https://chromewebstore.google.com/detail/pelagus/gaegollnpijhedifeeeepdoffkgfcmbc) | Older version of Pelagus Wallet that supports the older Iron Age Address format. | | [Pelagus Docs](https://pelaguswallet.io/docs/) | Pelagus Wallet documentation. | | [Example Pelagus App](https://github.com/PelagusWallet/pelagus-e2e-dapp) | Example application using Pelagus Wallet. | ## Smart Contracts | | | | ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | | [Supported Languages](/build/smart-contracts/languages/) | Supported smart contract languages on Quai Network. | | [Deployment Tutorials](/guides/development/) | Tutorials on how to deploy smart contracts on Quai Network. | | [Deployment Examples](https://github.com/dominant-strategies/hardhat-example) | Example repository for deploying smart contracts on Quai Network. | | [quai-hardhat-plugin npm package](https://www.npmjs.com/package/quai-hardhat-plugin) | A plugin built for Hardhat that provides support for deploying smart contracts on Quai Network. | ## Open Source Applications | | | | ------------------------------------------------------------------------------------- | -------------------------------------------------------------- | | [quai-next-dapp](https://github.com/dominant-strategies/quai-next-dapp) | Boilerplate application built using Pelagus and Quaiscan APIs. | | [quai-no-code-deployer](https://github.com/dominant-strategies/quai-no-code-deployer) | No-code smart contract deployment tool for Quai Network. | | [pelagus-e2e-dapp](https://github.com/PelagusWallet/pelagus-e2e-dapp) | Example application using Pelagus Wallet. | # Deploy Source: https://docs.qu.ai/build/smart-contracts/deployment How to deploy a smart contract to the Quai Network. To deploy a smart contract on Quai Network, you simply send a transaction containing the contract bytecode without specifying a recipient. Once deployed, your smart contract will be available to any user on the network to interact with. ## How to Deploy a Smart Contract ### Requirements To deploy a smart contract on Quai, you'll need a few things: * *QUAI to cover gas*: similar to a normal transaction, you'll need to set your gas limit. Be aware that contract deployment requires significantly more gas than a simple transfer. * *Contract Bytecode*: generated using a [compiler](https://www.alchemy.com/overviews/solidity-compiler). * *Deployment script or plugin* * *Access to a Quai node*: you can do this either by [running your own node](/guides/client/node), [accessing a publicly available node](/build/networks), or through API key via a node service. ### Deployment Smart contracts on Quai Network can be deployed using a number of different methods. The most straightforward and widely used methods are using deployment tools like Hardhat. Contracts can also be deployed using the quais.js library, which offers increased flexibility and the ability to deploy via frontend or simple script. Information on how to deploy a simple smart contract with hardhat can be found in the [Solidity Deployment Tutorial](/guides/development/solidity). ## Cross-Chain Smart Contracts Documentation for deploying cross-chain smart contracts with SolidityX is coming soon. Developers interested in converting their existing contracts to be cross-chain compatible in the future should implement upgradeable (proxy) patterns. Contrary to monolithic blockchains, Quai Network's multi-threaded architecture allows for the deployment of cross-chain smart contracts. These are smart contracts present in a single network context that contain references to sister contracts in alternate context(s). Multi-chain referencing smart contracts allow you as a developer to create seamless cross-chain applications that can: * Asynchronously track the state of contracts within other chains in the network * Natively transfer value and tokens to different contexts without bridges * Create a network secured mesh of smart contracts ### Cross-Chain Deployment Sister contracts are created by deploying contracts across all chains that the project intends to support. After the deployment of these sister contracts, a trust on first-use (TOFU) strategy is used to link the contracts together, allowing each contract to be aware of the state and activities of all of its sisters. Each sister contract contains an objective reference to the public address of every other sister contract. Contracts intended to function across many chains will contain initially empty slots for the addresses of its sisters. If a contract intends to maintain functionality across the initial network of 9 chains, 8 slots are required for all 8 sister contracts to be referenced. # Opcode Additions Source: https://docs.qu.ai/build/smart-contracts/opcode-additions Specification of the isaddrinternal and etx opcodes additions on Quai Network. # What Are EVM Opcodes? Opcodes are the individual low-level instructions that make up a smart contract on the Ethereum Virtual Machine (EVM). Each opcode corresponds to a specific operation that the EVM can perform, such as adding or comparing values in memory, or interacting with the blockchain. Opcodes are executed one at a time in the order they appear in a contract's bytecode. The set of opcodes available on the EVM is fixed and limited, but they provide a powerful set of building blocks for creating complex smart contracts. ## Quai Specific Opcodes Quai Network's implementation of the EVM introduces two new opcodes for developers to utilize. Checks if provided address is within smart contract's context. Emits an external transaction from a smart contract. Emits an external transaction from a smart contract that converts quai to qi. Each of these opcodes serves a very specific purpose within Quai Network's VM. isaddrinternal allows smart contracts to determine whether a contract interaction can occur entirely within a single context or whether an ETX needs to occur. Based on the boolean response from isaddrinternal, a smart contract can continue on as normal with a local interaction, or can emit an ETX using the etx opcode. ## Assembly Implementation Solidity does not currently have native compiler support for Quai's additional opcodes that provide cross-chain functionality, but it does have support for [inline assembly usage](https://docs.soliditylang.org/en/latest/assembly.html). Inline assembly is typically implemented by developers for more fine-grained control over your contract. In the context of Quai, we can use it to directly call opcodes inside of contracts via Yul and Assembly. This allows us to maintain the same general structure as traditional Solidity based contract while implementing simple assembly to provide functionality for Quai specific utilities. Inline assembly within Solidity is generally straightforward as you can access your contract's variables via normal methods and insert directly into assembly. The syntax for inserting assembly into your contract is as follows: ```solidity theme={null} function doSomethingWithAssembly() { assembly {...} } ``` More information on case specific syntax, usage and conventions can be found on the Solidity [inline assembly page](https://docs.soliditylang.org/en/latest/assembly.html). ## Examples As mentioned above, the `isaddrinternal` opcode is used to verify that an address is within a specific chain's scope. It is most often used in contracts to determine whether the contract should initiate a traditional in-scope transaction or opt for an external transaction. Below is a simple implementation of the opcode in a ERC20 smart contract: ```solidity theme={null} function transfer(address to, uint256 amount) public payable returns (bool) { bool isInternal; assembly { isInternal := isaddrinternal(to) // This opcode returns true if an address is internal } require(isInternal, "Address is external. Use cross-chain transfer function."); _transfer(msg.sender, to, amount); return true; } ``` The `transfer` function handles token transfers between two wallets. Inline assembly and the `isaddrinternal` opcode are used to verify that an address is internal. If the check returns true, the function executes the transfer normally. If the check returns false, the transfer is not executed and the user is directed to utilize another function to complete a cross-chain transfer. External transactions, also called a cross-chain transfers, can be initiated by smart contract via the `etx` opcode. A basic example of `etx` implementation in the same ERC20 contract from the isaddrinternal can be seen below. The `crossChainTransfer` function should be called if the check inside of transfer returns false. ```solidity theme={null} /** * This function sends tokens to an address on another chain by creating an external transaction (ETX). * This function uses opETX which constructs an external transaction and adds it to the block. * The ETX will make its way over to the destination and automatically execute when the given base fee is correct. * `to` must be an address on a different chain. The chain of a given address is determined by the first byte of the address. * gasLimit, minerTip and basefee are for executing the transaction on the destination chain. Choose these carefully. * The base fee and miner tip are in Wei and may not be the same as they are on your current chain. * If the base fee or miner tip are too low, the ETX will wait in the destination chain until they are high enough to be added in a block. * You must send a value with the function call equal to the following amount: (baseFee + minerTip) * gasLimit */ function crossChainTransfer(address to, uint256 amount, uint256 gasLimit, uint256 minerTip, uint256 baseFee) public payable { bool isInternal; assembly { isInternal := isaddrinternal(to) // This opcode returns true if an address is internal } require(!isInternal, "Address is not external"); _burn(msg.sender, amount); address toAddr = ApprovedAddresses[getAddressLocation(to)]; uint totalGas = (baseFee + minerTip) * gasLimit; require(msg.value >= totalGas, string(abi.encodePacked("Not enough gas sent, need at least ", uint2str(totalGas), " wei"))); bytes memory encoded = abi.encodeWithSignature("incomingTransfer(address,uint256)", to, amount); bool success; // this is not used. opETX only returns false if there was an error in creating the ETX, not executing it. assembly { success := etx( 0, // temp variable, can be anything (unused) toAddr, // address to send to 0, // amount to send in wei gasLimit, // gas limit (entire gas limit will be consumed and sent to destination) minerTip, // miner tip in wei baseFee, // base fee in wei add(encoded, 0x20), // input offset in memory (the first 32 byte number is just the size of the array) mload(encoded), // input size in memory (loading the first number gives the size) 0, // accesslist offset in memory 0 // accesslist size in memory ) } emit ExternalTransfer(msg.sender, to, amount); } ``` `crossChainTransfer` utilizes an initial check to ensure that the destination is address is outside of the current context scope. The contract then executes in this fashion: Burns the provided `amount` of tokens on the origin chain. Sets the `toAddr` to the public key of a sister contract on the destination chain. Calculates the `totalGas` provided by the user *and* checks that the provided gas is sufficient to execute the transaction. Encodes the transaction data being sent to the destination chain into `encoded`. Constructs the external transaction using the `etx` opcode via inline assembly. Emits the transaction from the contract to be mined on the origin chain and routed to the destination chain. ## Conclusion The `isaddrinternal` and `etx` opcodes provide key cross-chain functionality to smart contracts deployed on Quai Network. The `convert` opcode provides functionality to convert tokens from Quai ledger to Qi ledger. They provide the basis for contracts in different contexts to communicate and interact with each other in a trustless fashion and allow developers to create multi-chain applications that span the entire network. # Solidity Source: https://docs.qu.ai/build/smart-contracts/solidity The Solidity smart contract programming language. ## Overview Solidity is a contract-oriented, high-level programming language for creating smart contracts. It was influenced by C++, Python, and JavaScript and is designed to target the Ethereum Virtual Machine (EVM) environments. Solidity is statically typed, supports inheritance, and libraries. It allows developers to create smart contracts for a wide range of use cases and applications. Key features of Solidity include: * Complex user-defined types * Inheritance and complex user-defined contracts * Error checking, including requirements and assertions * Support for libraries and user-defined functions * Strong security features that ensure contract integrity. The Quai Network EVM supports Solidity versions up to [0.8.19](https://github.com/ethereum/solidity/releases/tag/v0.8.19). Using a newer version of Solidity may result in errors when deploying smart contracts. ## Example Contract The Greeter contract shown below is written with [Solidity v0.8.0](https://docs.soliditylang.org/en/v0.8.0/). Greeter serves two functions: * Store a greeting on-chain. * Return the greeting when the contract function is called. It also contains a function for users to set a new greeting of their choice. While the Greeter contract may be simple, it showcases some of the unique functionality that smart contracts offer. ```solidity Greeter.sol theme={null} // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Greeter { string private greeting; function greet() public view returns (string memory) { return greeting; } function setGreeting(string memory _greeting) public { console.log("Changing greeting from '%s' to '%s'", greeting, _greeting); greeting = _greeting; } } ``` ## Resources | | | | ---------------------------------------------------------------------------- | -------------------------------------------------------------------- | | [Solidity Homepage](https://soliditylang.org/) | The official Solidity homepage. | | [Solidity Documentation](https://docs.soliditylang.org/en/v0.8.19/) | The official Solidity documentation. | | [GitHub](https://github.com/ethereum/solidity) | The Solidity GitHub Repository. | | [Examples](https://docs.soliditylang.org/en/latest/solidity-by-example.html) | Solidity by Example - a collection of example contracts in Solidity. | # Overview Source: https://docs.qu.ai/build/transactions/overview An overview of transactions within Quai Network. # What Are Transactions? Transactions are cryptographically signed messages sent to and executed on Zone chains within Quai Network. Regardless of what ledger or chain you are on within the network, every state-changing operation requires a signed transaction. Transactions are executed independently for each Zone chain and for each ledger (Quai or Qi). ## Transaction Types in Quai Network Quai Network transactions are split into 3 different types, or categories depending on where they are executed. A transaction executed on the Quai ledger within a single shard. Transactions that cross shards or serve special network functions, such as miner payouts or Quai/Qi conversions. A transaction executed on the Qi ledger within a single shard. # Types Source: https://docs.qu.ai/build/transactions/types Transaction types in Quai Network. # Overview Quai Network transactions are split into 3 different types, or categories depending on where they are executed. * **Type 0: Quai Transaction**: A transaction executed on the Quai ledger within a single shard. * **Type 1: External Transaction**: Transactions that cross shards or serve special network functions, such as miner payouts or Quai/Qi conversions. * **Type 2: Qi Transaction**: UTXO style transactions processed on the Qi Ledger. ## Type 0: Quai Transaction Type 0 transactions are transactions that are executed within a single shard on the Quai ledger. They follow a similar format to traditional EVM transactions and can be used to transfer Quai tokens, interact with a smart contract, or deploy a new smart contract. ### Structure ```json theme={null} { "from": "0x000057fad1aa3fb866a7fbe1f03429dfb1a62456", "gas": "0xf618", "gasPrice": "0xa410", "hash": "0x0002000ff641b8ab3c9f6b356ed2916a77039689d95184635cbfec8ba85b5dbd", "input": "0x", "nonce": "0x7", "to": "0x1228d3ed4aedc881d950726cd9d98d051cc2c643", "value": "0x5", "type": "0x0", "accessList": [], "chainId": "0x2328", "v": "0x0", "r": "0x5b30dbe83dca992a3f9633c305c34a0da4d67a64281c3764fc17a5ecbc9794b7", "s": "0x571e56e75b58550c8d9fb64268c4ef53606882155a1a5b73ad344a4605a97a3", } ``` For Quai transactions, the `type` field is always `0x0`. ### Key Properties * ECDSA signatures (V, R, S) * Includes `chainID` and `nonce` fields for replay protection * Support for [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) style gas pricing * Includes `accessList` field for [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) support ## Type 1: External Transaction Type 1 transactions can be split into 5 sub-types: * 0 **Cross-Shard Transactions**: Used for transferring value or data between different shards. * 1 **Coinbase Transactions**: Special transactions that payout block rewards and fees. * 2 **Conversion Transactions**: Native protocol conversions between Quai and Qi. * 3 **Coinbase Lockup Transactions**: Used for locking up coinbase rewards on a contract address. * 4 **Wrapping Qi Transactions**: Used for wrapping Qi tokens on Quai ledger. * 5 **Conversion Revert Transactions**: Used for conversion etxs that revert and the original amount is refunded. * 6 **UnWrap Qi Transactions**: Used when Qi is unwrapped from the wrapped qi contract to return the Wrapped Qi back to the Qi ledger. Type 1 transactions, regardless of subtype, are never directly initiated by a user. They are always intiated directly by the protocol, following either a Type 0 or Type 2 transferring value across shards, a network designated miner payout, or a Quai/Qi conversion also initiated following a Type 0 or Type 2 transaction. Last 32 bytes of the input field of External Transaction type (Coinbase, Coinbase Lockup) has the workshare hash for which this payment is generated for. ### Structure ```json theme={null} { "originatingTxHash": "0x0002000ff641b8ab3c9f6b356ed2916a77039689d95184635cbfec8ba85b5dbd", "etxIndex": "0x3", "gas": "0xf618", "to": "0x1228d3ed4aedc881d950726cd9d98d051cc2c643", "value": "0x5", "input": "0x000x0002000ff641b8ab3c9f6b356ed2916a77039689d95184635cbfec8ba85b5dbd", "sender": "0x000057fad1aa3fb866a7fbe1f03429dfb1a62456", "etxType": "0x0" } ``` ### Key Properties * Includes `etxType` property to indicate the transaction sub-type. Available subtypes are `coinbaseLockup`, `wrapQi`, `unwrapQi`, `coinbase`, `conversion`, and `etx` * Contains the `originatingTxHash` to identify the transaction that initiated the Type 1 transaction * Includes `ETXIndex` for ordering multiple external transactions from a single origin * Does not include or require any signatures ## Type 2: Qi Transaction Type 2 transactions are transactions that are executed within a single shard on the Qi ledger. They follow a similar format to traditional UTXO transactions and can be used to transfer Qi tokens of specific denominations. Qi Transactions utilize previous unspent outputs of an address as inputs for every transaction. ### Structure ```json theme={null} { "txIns": [ { "PreviousOutPoint": { "TxHash": "0x9c26a92ea692273abeaa3a8b0349715938c81bc7a897e496eec1fc3963f4ac32", "Index": 0 }, "Pubkey": "0x0080017fc240B17F94Ed1a9b7450E9096D43223E" } ], "txOuts": [ { "Denomination": 15, "Address": "0x1228d3ed4aedc881d950726cd9d98d051cc2c643", "Lock": 0 } ], "txType": 2 } ``` The `txType` field is always `2` for Qi transactions. ### Key Properties * Uses Schnorr and Musig signatures * UTXO-like input and output transaction structures * Does not include gas or data related fields # Lectures & Presentations Source: https://docs.qu.ai/learn/academic-resources/lectures A collection of lectures and presentations on the technology powering Quai Network. ## The PoEM Consensus Mechanism: ACSAC 2023 Keynote Presentations **December 9 2023** Quai co-founder Dr. K was invited to give a keynote presentation at the 39th Annual Computer Security Applications Conference (ACSAC) in December 2023.