### Build Qiyichain Java SDK from Source Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Build the Qiyichain Java SDK directly from its source code using Maven. This process involves cloning the repository, navigating into the directory, and executing the clean install command to build and install the SDK into your local Maven repository. ```bash # Clone the repository git clone https://github.com/qiyichain/qiyichain-java-sdk.git cd qiyichain-java-sdk # Build and install to local Maven repository mvn clean install # The JAR will be available at: target/qiyichain-java-sdk.jar ``` -------------------------------- ### Call Generic Contract View Method in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Enables calling any view or pure method on a smart contract without gas consumption. The example demonstrates calling the `totalSupply()` method on an ERC20 contract. It requires initializing the environment, specifying input and output parameters, and using `TransactionFace.callContractViewMethod`. ```java import com.qiyichain.face.TransactionFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.abi.TypeReference; import org.web3j.abi.datatypes.*; import org.web3j.abi.datatypes.generated.Uint256; import java.util.*; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Example: Call totalSupply() on an ERC20 contract String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; // Input parameters (empty for totalSupply) List inputParams = new ArrayList<>(); // Output parameters (Uint256 for totalSupply) List> outputParams = new ArrayList<>(); outputParams.add(new TypeReference() {}); // Call the view method List results = TransactionFace.callContractViewMethod( contractAddress, "totalSupply", inputParams, outputParams ); if (results != null && results.size() == 1) { Uint256 totalSupply = (Uint256) results.get(0); System.out.println("Total Supply: " + totalSupply.getValue()); } ``` -------------------------------- ### Query Token Contract Name in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Retrieves the full name of a token contract. This function initializes the Qiyichain environment and uses CoinFace.getName to get the token's name, which is then printed to the standard output. An example output is included. ```java import com.qiyichain.face.CoinFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query contract name String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String name = CoinFace.getName(contractAddress); System.out.println("Token Name: " + name); // Example output: "Tether USD" ``` -------------------------------- ### Query Token Contract Symbol in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Fetches the symbol or ticker of a token contract. The code initializes the environment and uses CoinFace.getSymbol to retrieve the token symbol, then prints it to the console. An example output is provided. ```java import com.qiyichain.face.CoinFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query contract symbol String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String symbol = CoinFace.getSymbol(contractAddress); System.out.println("Token Symbol: " + symbol); // Example output: "USDT" ``` -------------------------------- ### Get Account Nonce (Java) Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Retrieve the current nonce for an account address, which is crucial for ensuring the correct ordering of transactions. It supports fetching the nonce from the 'latest' block for sequential transactions or the 'pending' block for parallel transaction queuing. ```java import com.qiyichain.face.TransactionFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; import java.util.concurrent.ExecutionException; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); String accountAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; // Option 1: Get nonce from LATEST block (for sequential transactions) BigInteger nonceLatest = TransactionFace.getNonce( accountAddress, DefaultBlockParameterName.LATEST ); System.out.println("LATEST Nonce: " + nonceLatest); // Use when: Submitting one transaction at a time from same address // Option 2: Get nonce from PENDING transactions (recommended for parallel) BigInteger noncePending = TransactionFace.getNonce( accountAddress, DefaultBlockParameterName.PENDING ); System.out.println("PENDING Nonce: " + noncePending); // Use when: Need to queue multiple transactions // Returns next available nonce including pending transactions ``` -------------------------------- ### Get NFT Contract Address from Deployment Hash Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Retrieves the deployed NFT contract address by decoding information from a given deployment transaction hash. This function is useful for dynamically obtaining contract addresses after deployment. It requires the transaction hash as input and returns the contract address as a string. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get contract address from deployment transaction String deploymentTxHash = "0x2e07df344340ea46626aad1d82559fb02676054472c42c208d025565403e614d"; String nftContractAddress = NFTFace.decodeContractAddressFromLog(deploymentTxHash); if (nftContractAddress != null) { System.out.println("NFT Contract Address: " + nftContractAddress); } else { System.out.println("Contract address not found or transaction not confirmed"); } ``` -------------------------------- ### Smart Contract Queries Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt APIs for querying information from deployed smart contracts. ```APIDOC ## GET /contracts/{contractAddress}/owner ### Description Retrieve the owner address of a smart contract. This requires the contract to have a public owner field. ### Method GET ### Endpoint `/contracts/{contractAddress}/owner` ### Parameters #### Path Parameters - **contractAddress** (string) - Required - The address of the smart contract. ### Request Example ```java // Example Java code to query contract owner String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String ownerAddress = CoinFace.getOwner(contractAddress); ``` ### Response #### Success Response (200) - **ownerAddress** (string) - The address of the contract owner. #### Response Example ```json { "ownerAddress": "0xabcdef1234567890abcdef1234567890abcdef12" } ``` ``` ```APIDOC ## GET /contracts/{contractAddress}/symbol ### Description Get the symbol or ticker of a token contract. ### Method GET ### Endpoint `/contracts/{contractAddress}/symbol` ### Parameters #### Path Parameters - **contractAddress** (string) - Required - The address of the token contract. ### Request Example ```java // Example Java code to query token symbol String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String symbol = CoinFace.getSymbol(contractAddress); ``` ### Response #### Success Response (200) - **symbol** (string) - The symbol of the token. #### Response Example ```json { "symbol": "USDT" } ``` ``` ```APIDOC ## GET /contracts/{contractAddress}/name ### Description Retrieve the full name of a token contract. ### Method GET ### Endpoint `/contracts/{contractAddress}/name` ### Parameters #### Path Parameters - **contractAddress** (string) - Required - The address of the token contract. ### Request Example ```java // Example Java code to query token name String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String name = CoinFace.getName(contractAddress); ``` ### Response #### Success Response (200) - **name** (string) - The full name of the token. #### Response Example ```json { "name": "Tether USD" } ``` ``` ```APIDOC ## POST /contracts/read ### Description Call any view or pure method on a smart contract without consuming gas. This is a generic method for reading contract state. ### Method POST ### Endpoint `/contracts/read` ### Parameters #### Request Body - **contractAddress** (string) - Required - The address of the smart contract. - **methodName** (string) - Required - The name of the view/pure method to call. - **inputParams** (array) - Optional - An array of input parameters for the method. Each element should be a Web3j-compatible type. - **outputParams** (array) - Required - An array of TypeReferences defining the expected output types of the method. ### Request Example ```java // Example Java code to call a view method (totalSupply) String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; List inputParams = new ArrayList<>(); List> outputParams = new ArrayList<>(); outputParams.add(new TypeReference() {}); // Assuming TransactionFace.callContractViewMethod is available // List results = TransactionFace.callContractViewMethod( // contractAddress, // "totalSupply", // inputParams, // outputParams // ); ``` ### Response #### Success Response (200) - **results** (array) - An array of Type objects representing the returned values from the contract method. #### Response Example ```json { "results": [ { "type": "Uint256", "value": "1000000000000000000" } ] } ``` ``` -------------------------------- ### Import Wallet from Mnemonic in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Restores wallet credentials from a 12-word mnemonic phrase. This is an offline operation and does not require SDK initialization. ```java import com.qiyichain.face.AccountFace; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; // Import account using mnemonic (offline operation) String mnemonic = "word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12"; String accountJson = AccountFace.importByMnemonic(mnemonic); JSONObject account = JSON.parseObject(accountJson); System.out.println("Restored Address: " + account.getString("address")); System.out.println("Private Key: " + account.getString("pri")); ``` -------------------------------- ### Query ERC20 Token Balance in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Queries the balance of ERC20 standard smart contract tokens for a given wallet address and token contract address. Requires SDK initialization. The token's decimal places must be provided. ```java import com.qiyichain.face.AccountFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import java.math.BigDecimal; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query ERC20 token balance String walletAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; String tokenContract = "0x1234567890abcdef1234567890abcdef12345678"; Integer decimals = 18; // Token decimal places (commonly 18) BigDecimal tokenBalance = AccountFace.getContractCoinBalance(walletAddress, tokenContract, decimals); System.out.println("Token Balance: " + tokenBalance.toPlainString()); ``` -------------------------------- ### Create New Wallet in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Generates a new blockchain wallet including mnemonic phrase, private key, public key, and address. This is an offline operation and does not require SDK initialization. ```java import com.qiyichain.face.AccountFace; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; // Create a new account (offline operation - no initialization required) String accountJson = AccountFace.createAccount(); JSONObject account = JSON.parseObject(accountJson); System.out.println("Mnemonic: " + account.getString("mnemonic")); System.out.println("Private Key: " + account.getString("pri")); System.out.println("Address (0x): " + account.getString("address")); System.out.println("Public Key: " + account.getString("pub")); // Example output: // { // "mnemonic": "word1 word2 word3 ... word12", // "pri": "0x1234567890abcdef...", // "address": "0xabcdef1234567890...", // "pub": "0x04abcdef..." // } ``` -------------------------------- ### Query GAS Balance in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Checks the main network GAS token balance for a given address. This is an online operation and requires SDK initialization with a node endpoint and chain ID. Supports both 0x and Bech32 address formats. ```java import com.qiyichain.face.AccountFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import java.math.BigDecimal; // Initialize environment (required for online operations) EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // mainnet: 2285, testnet: 12285 // Query GAS balance using address (supports both 0x and Bech32 formats) String address = "0xabcdef1234567890abcdef1234567890abcdef12"; BigDecimal balance = AccountFace.getMainCoinBalance(address); System.out.println("GAS Balance: " + balance.toPlainString() + " QYC"); // Example output: 125.5 QYC ``` -------------------------------- ### Convert Address Formats in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Provides utilities to convert between Bech32 and hexadecimal (0x) address formats on the Qiyichain network. This is an offline operation. ```java import com.qiyichain.face.AccountFace; // Convert Bech32 address to 0x format String bech32Address = "qyc1abc123def456..."; String hexAddress = AccountFace.addressToHex(bech32Address); System.out.println("Hex Address: " + hexAddress); // Output: 0xabcdef1234567890... // Convert 0x address to Bech32 format String hexAddr = "0xabcdef1234567890abcdef1234567890abcdef12"; String bech32Addr = AccountFace.hexToAddress(hexAddr); System.out.println("Bech32 Address: " + bech32Addr); // Output: qyc1abc123def456... ``` -------------------------------- ### NFT Operations Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt APIs for deploying and managing Non-Fungible Tokens (NFTs). ```APIDOC ## POST /nft/erc721a/deploy ### Description Deploy a new digital collectible (NFT) smart contract using the ERC721A standard. This operation requires a whitelisted account for the factory contract. ### Method POST ### Endpoint `/nft/erc721a/deploy` ### Parameters #### Request Body - **privateKey** (string) - Required - The private key of the deployer account. - **factoryContract** (string) - Required - The address of the whitelisted factory contract. - **collectionName** (string) - Required - The name of the NFT collection. - **symbol** (string) - Required - The symbol/ticker for the NFT collection. - **baseUri** (string) - Required - The base URI for NFT metadata (e.g., IPFS or OSS directory URL). - **uniqueId** (BigInteger) - Required - A unique identifier for this deployment. - **mintImmediately** (boolean) - Required - Whether to mint tokens immediately upon deployment. - **mintAmount** (BigInteger) - Optional - The number of tokens to mint if `mintImmediately` is true. - **ownerAddress** (string) - Required - The address that will own the deployed contract. - **nonce** (BigInteger) - Required - The nonce for the transaction. ### Request Example ```java // Example Java code for deploying ERC721A NFT String privateKey = "0x1234567890abcdef..."; String factoryContract = "0xFactory123456789abcdef..."; String collectionName = "My NFT Collection"; String symbol = "MNFT"; String baseUri = "ipfs://QmHash123.../"; BigInteger uniqueId = new BigInteger("12345"); boolean mintImmediately = true; BigInteger mintAmount = new BigInteger("100"); String ownerAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(ownerAddress, DefaultBlockParameterName.PENDING); // Assuming NFTFace.deployERC721AFast is available // FastMsg result = NFTFace.deployERC721AFast( // privateKey, factoryContract, collectionName, symbol, baseUri, // uniqueId, mintImmediately, mintAmount, ownerAddress, nonce // ); ``` ### Response #### Success Response (200) - **hash** (string) - The transaction hash of the deployment. #### Response Example ```json { "hash": "0xabc123...def456" } ``` #### Error Response (400) - **message** (string) - A message describing the failure. #### Error Response Example ```json { "message": "Deployment Failed: Insufficient balance or invalid parameters." } ``` ``` -------------------------------- ### Deploy ERC721A NFT Contract in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Deploys a new digital collectible (NFT) smart contract using the ERC721A standard. This operation requires a whitelisted account. The function `NFTFace.deployERC721AFast` is used, requiring parameters like private key, factory contract address, collection details, and deployment options. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.msg.coin.FastMsg; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get current nonce for the account String privateKey = "0x1234567890abcdef..."; String fromAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(fromAddress, DefaultBlockParameterName.PENDING); // Deploy ERC721A NFT collection String factoryContract = "0xFactory123456789abcdef..."; // Factory contract (must be whitelisted) String collectionName = "My NFT Collection"; String symbol = "MNFT"; String baseUri = "ipfs://QmHash123.../"; // IPFS or OSS directory URL BigInteger uniqueId = new BigInteger("12345"); // Unique deployment ID boolean mintImmediately = true; // Mint tokens during deployment BigInteger mintAmount = new BigInteger("100"); // Number to mint String ownerAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; FastMsg result = NFTFace.deployERC721AFast( privateKey, factoryContract, collectionName, symbol, baseUri, uniqueId, mintImmediately, mintAmount, ownerAddress, nonce ); if (result.isSuccess()) { System.out.println("Deployment Transaction Hash: " + result.getHash()); // Use the hash to retrieve contract address later } else { System.out.println("Deployment Failed: " + result.getMsg()); } ``` -------------------------------- ### Import Wallet from Private Key in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Recovers wallet credentials using a private key. Note that the mnemonic phrase cannot be recovered from the private key. This is an offline operation. ```java import com.qiyichain.face.AccountFace; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; // Import account using private key (offline operation) String privateKey = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"; String accountJson = AccountFace.importByPrivateKey(privateKey); JSONObject account = JSON.parseObject(accountJson); System.out.println("Address: " + account.getString("address")); System.out.println("Public Key: " + account.getString("pub")); // Note: mnemonic field will be empty "" ``` -------------------------------- ### Add Qiyichain Java SDK Maven Dependency Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Integrate the Qiyichain Java SDK into your Maven project by adding the dependency to your pom.xml. If dependency conflicts arise, explicitly include the Guava library. ```xml com.qiyichain qiyichain-java-sdk 0.18.0 com.google.guava guava 30.1-jre ``` -------------------------------- ### Generic Contract Write Method (Java) Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Execute state-changing methods on a smart contract. This method requires the sender's private key, contract address, input parameters, function name, gas limit, gas price, and the account's nonce. It is used for operations that modify the contract's state and consume gas. ```java import com.qiyichain.face.TransactionFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.abi.datatypes.*; import org.web3j.abi.datatypes.generated.Uint256; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; import java.util.*; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get nonce String privateKey = "0x1234567890abcdef..."; String fromAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(fromAddress, DefaultBlockParameterName.PENDING); // Example: Call approve() on ERC20 contract String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String spenderAddress = "0x9999888877776666555544443333222211110000"; BigInteger approveAmount = new BigInteger("1000000000000000000"); // 1 token (18 decimals) // Prepare input parameters List inputParams = Arrays.asList( new Address(spenderAddress), new Uint256(approveAmount) ); // Gas settings BigInteger gasLimit = new BigInteger("100000"); BigInteger gasPrice = new BigInteger("10"); // Will be multiplied by 10^8 internally // Execute contract function String txHash = TransactionFace.callContractFunctionOpByNonce( privateKey, contractAddress, inputParams, "approve", gasLimit, gasPrice, nonce ); if (txHash != null) { System.out.println("Transaction Hash: " + txHash); } else { System.out.println("Transaction failed"); } ``` -------------------------------- ### Mint NFTs using Qiyichain Java SDK Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Mints a specified quantity of new non-fungible tokens (NFTs) on the Qiyichain blockchain. This operation requires the private key of the sender, the NFT contract address, the quantity to mint, and the current transaction nonce. It returns a BaseMsg object indicating success or failure and the transaction hash if successful. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.face.TransactionFace; import com.qiyichain.msg.coin.BaseMsg; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get current nonce String privateKey = "0x1234567890abcdef..."; String fromAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(fromAddress, DefaultBlockParameterName.PENDING); // Mint NFTs String nftContract = "0x9876543210fedcba9876543210fedcba98765432"; BigInteger quantity = new BigInteger("50"); // Number of NFTs to mint BaseMsg mintResult = NFTFace.mintByNonce(privateKey, nftContract, quantity, nonce); if (mintResult.isSuccess()) { System.out.println("Mint Transaction Hash: " + mintResult.getHash()); } else { System.out.println("Mint Failed: " + mintResult.getMsg()); } ``` -------------------------------- ### Query Smart Contract Owner Address in Java Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Retrieves the owner address of a smart contract. This method requires the contract to have a public owner field. It initializes the environment, queries the owner using CoinFace.getOwner, and prints the result or an error message if the owner field is not accessible. ```java import com.qiyichain.face.CoinFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query contract owner String contractAddress = "0x1234567890abcdef1234567890abcdef12345678"; String ownerAddress = CoinFace.getOwner(contractAddress); if (ownerAddress != null) { System.out.println("Contract Owner: " + ownerAddress); } else { System.out.println("Owner field not accessible"); } ``` -------------------------------- ### Query Transaction Status (Java) Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Check the confirmation status of a transaction using its hash. This method is useful for verifying if a transaction has been successfully processed on the blockchain. It includes a retry mechanism with a delay to account for potential network latency. ```java import com.qiyichain.face.TransactionFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query transaction status String txHash = "0x2e07df344340ea46626aad1d82559fb02676054472c42c208d025565403e614d"; // Retry logic for transaction confirmation (recommended: up to 10 retries with 1-second delay) boolean confirmed = false; int maxRetries = 10; for (int i = 0; i < maxRetries; i++) { boolean status = TransactionFace.getTransactionStatus(txHash); if (status) { System.out.println("Transaction Confirmed Successfully!"); confirmed = true; break; } System.out.println("Attempt " + (i + 1) + ": Transaction pending..."); try { Thread.sleep(1000); // Wait 1 second before retry } catch (InterruptedException e) { e.printStackTrace(); } } if (!confirmed) { System.out.println("Transaction failed or not found after " + maxRetries + " attempts"); } ``` -------------------------------- ### Query NFT Owner Address Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Checks and retrieves the owner's address for a specific NFT token. This function requires the NFT contract address and the token ID as input. It returns the owner's address as a string or null if the token is not found or the query fails. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import java.math.BigInteger; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Query owner of specific token String nftContract = "0x9876543210fedcba9876543210fedcba98765432"; BigInteger tokenId = new BigInteger("42"); String ownerAddress = NFTFace.ownerOf(nftContract, tokenId); if (ownerAddress != null) { System.out.println("Token #" + tokenId + " is owned by: " + ownerAddress); } else { System.out.println("Token not found or query failed"); } ``` -------------------------------- ### Transfer GAS Tokens (Java) Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Send native GAS tokens to a specified recipient address. This function requires the sender's private key, the amount to transfer, and the recipient's address. It returns a BaseMsg object containing transaction details or an error message. ```java import com.qiyichain.face.TransactionFace; import com.qiyichain.msg.coin.BaseMsg; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Transfer GAS String senderPrivateKey = "0x1234567890abcdef..."; String amount = "1.5"; // Amount in QYC (not wei) String recipientAddress = "0x9999888877776666555544443333222211110000"; BaseMsg transferResult = TransactionFace.sendCommonAndGet( senderPrivateKey, amount, recipientAddress ); if (transferResult.isSuccess()) { System.out.println("Transfer Transaction Hash: " + transferResult.getHash()); } else { System.out.println("Transfer Failed: " + transferResult.getMsg()); } ``` -------------------------------- ### Transfer NFT Ownership Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Transfers ownership of a specific NFT token from the current owner to a new recipient. This operation requires the sender's private key, the NFT contract address, the recipient's address, the token ID, and the current transaction nonce. It returns a FastMsg object detailing the transaction status and hash. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.face.TransactionFace; import com.qiyichain.msg.coin.FastMsg; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get current nonce String privateKey = "0x1234567890abcdef..."; String fromAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(fromAddress, DefaultBlockParameterName.PENDING); // Transfer NFT String nftContract = "0x9876543210fedcba9876543210fedcba98765432"; String recipientAddress = "0x9999888877776666555544443333222211110000"; BigInteger tokenId = new BigInteger("42"); FastMsg transferResult = NFTFace.transferFast( privateKey, nftContract, recipientAddress, tokenId, nonce ); if (transferResult.isSuccess()) { System.out.println("Transfer Transaction Hash: " + transferResult.getHash()); } else { System.out.println("Transfer Failed: " + transferResult.getMsg()); } ``` -------------------------------- ### Burn NFT Token Source: https://context7.com/qiyichain/qiyichain-java-sdk/llms.txt Permanently destroys an NFT token, making it unrecoverable. This operation requires the owner's private key, the NFT contract address, the token ID, and the current transaction nonce. It returns a FastMsg object indicating the transaction's success or failure and its hash. ```java import com.qiyichain.face.NFTFace; import com.qiyichain.face.TransactionFace; import com.qiyichain.msg.coin.FastMsg; import com.qiyichain.env.EnvBase; import com.qiyichain.env.EnvInstance; import org.web3j.protocol.core.DefaultBlockParameterName; import java.math.BigInteger; // Initialize environment EnvInstance.setEnv(new EnvBase("rpc.node.address", "2285")); // Get current nonce String privateKey = "0x1234567890abcdef..."; String fromAddress = "0xabcdef1234567890abcdef1234567890abcdef12"; BigInteger nonce = TransactionFace.getNonce(fromAddress, DefaultBlockParameterName.PENDING); // Burn NFT String nftContract = "0x9876543210fedcba9876543210fedcba98765432"; BigInteger tokenId = new BigInteger("42"); FastMsg burnResult = NFTFace.burnFast( privateKey, nftContract, tokenId, nonce ); if (burnResult.isSuccess()) { System.out.println("Burn Transaction Hash: " + burnResult.getHash()); } else { System.out.println("Burn Failed: " + burnResult.getMsg()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.