### Full Token Creation and Minting Example Source: https://docs.keeta.com/features/native-tokenization/token-creation/mint-tokens.md A comprehensive TypeScript example demonstrating the complete process of creating and minting a new token using the KeetaNet SDK. It includes account generation, client setup, token configuration, and transaction publishing. ```typescript import * as KeetaNet from "@keetanetwork/keetanet-client"; // Function to create and mint a new token async function createToken(userClient: KeetaNet.UserClient) { const builder = userClient.initBuilder(); // Generate the token account identifier const pendingTokenAccount = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN); await builder.computeBlocks(); const tokenAccount = pendingTokenAccount.account; // Set token info and permissions builder.setInfo( { name: '', // Token name (add as needed) description: '', // Description (add as needed) metadata: '', // Metadata (add as needed) defaultPermission: new KeetaNet.lib.Permissions([ 'ACCESS', // Public token ]), }, { account: tokenAccount }, ); // Increase (mint) total token supply and distribute the tokens builder.modifyTokenSupply(10_000n, { account: tokenAccount }); builder.send(account, 10_000n, tokenAccount, undefined, { account: tokenAccount }); // Publish the transaction to the network await builder.publish(); console.log("Token account created and minted."); return tokenAccount; } // Main function demonstrating token creation async function main() { // Generate a random seed for account creation const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); // Create a liquidity provider account from the seed const liquidityProviderAccount = KeetaNet.lib.Account.fromSeed(seed, 0); // Instantiate a user client connected to the test network const liquidityProviderClient = KeetaNet.UserClient.fromNetwork("test", liquidityProviderAccount); // Create and mint the token const tokenAccount = await createToken(liquidityProviderClient); // Log the token identifier that was created console.log("Token Account =", tokenAccount.publicKeyString.get()); // Log balances of the liquidity provider console.log("liquidityProviderClient.balances[] =", await liquidityProviderClient.allBalances()); } main() .then(() => { console.log("Done"); process.exit(0); }) .catch((err) => { console.error("Error:", err); process.exit(1); }); ``` -------------------------------- ### Complete Send Token Example Source: https://docs.keeta.com/components/blocks/operations/send.md A full example demonstrating loading the SDK, setting up accounts, defining recipients, building, and publishing a transaction to send 1 KTA. ```typescript const KeetaNet = require('@keetanetwork/keetanet-client'); // ⚠️ Demo seed, replace with working seed const DEMO_ACCOUNT_SEED = 'D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0'; async function main() { const sender = KeetaNet.lib.Account.fromSeed(DEMO_ACCOUNT_SEED, 0); const client = KeetaNet.UserClient.fromNetwork('test', sender); const recipient = KeetaNet.lib.Account.fromPublicKeyString( 'keeta_aabszsbrqppriqddrkptq5awubshpq3cgsoi4rc624xm6phdt74vo5w7wipwtmi' ); const builder = client.initBuilder(); builder.send(recipient, 1n, client.baseToken); // send 1 KTA await client.computeBuilderBlocks(builder); // optional but recommended await client.publishBuilder(builder); // send it to the network console.log('✅ Sent 1 KTA'); } main().catch(console.error); ``` -------------------------------- ### Mint and Burn Tokens Example Source: https://docs.keeta.com/features/native-tokenization/token-creation/burn-tokens.md This TypeScript example demonstrates how to create a new token account, mint an initial supply, and then burn a portion of that supply using the Keeta SDK. It includes generating a seed, initializing a user client, and publishing transactions to the network. Ensure you have the Keeta SDK installed and configured for the 'test' network. ```typescript import * as KeetaNet from "@keetanetwork/keetanet-client"; async function main() { // Generate random seed for account creation const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); // Create account and user client const account = KeetaNet.lib.Account.fromSeed(seed, 0); const userClient = KeetaNet.UserClient.fromNetwork("test", account); // Create and mint new token const builderMint = userClient.initBuilder(); const pendingTokenAccount = builderMint.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN); await builderMint.computeBlocks(); const tokenAccount = pendingTokenAccount.account; builderMint.setInfo( { name: '', description: '', metadata: '', defaultPermission: new KeetaNet.lib.Permissions(['ACCESS']), }, { account: tokenAccount } ); builderMint.modifyTokenSupply(10_000n, { account: tokenAccount }); await builderMint.publish(); console.log("Token account created and minted."); console.log("Balances after minting:", await userClient.allBalances()); // Burn some tokens const builderBurn = userClient.initBuilder(); builderBurn.modifyTokenSupply(-2_500n, { account: tokenAccount }); await builderBurn.publish(); console.log("2,500 tokens burned from account", tokenAccount.publicKeyString.toString()); console.log("Balances after burning:", await userClient.allBalances()); } main() .then(() => { console.log("Done"); process.exit(0); }) .catch((err) => { console.error("Error:", err); process.exit(1); }); ``` -------------------------------- ### Full Example: Minting and Burning Tokens Source: https://docs.keeta.com/components/blocks/operations/modifytokensupply.md A complete example demonstrating how to load a token account, initialize a builder, modify the token supply (either minting or burning), and publish the transaction. ```typescript // Step 1: Load token account const tokenAccount = Client.lib.Account.fromPublicKeyString(tokenPublicKey) if (!tokenAccount.isToken()) { throw new Error("Invalid token public key") } // Step 2: Start builder const builder = userClient.initBuilder() // Step 3a: Burn 100 tokens builder.modifyTokenSupply(-100n, { account: tokenAccount }) // Step 3b: Or mint 100 tokens builder.modifyTokenSupply(100n, { account: tokenAccount }) // Step 4: Publish the transaction await userClient.publishBuilder(builder) ``` -------------------------------- ### Full Code Example for Storage Account Creation Source: https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md This comprehensive example demonstrates the entire process of creating a token account, a storage account, and managing permissions for multiple user accounts. It includes account generation, client initialization, and publishing transactions. ```typescript import * as KeetaNet from "@keetanetwork/keetanet-client"; // Token creation function async function createToken(userClient: KeetaNet.UserClient) { const builder = userClient.initBuilder(); // Create a new token account const pendingTokenAccount = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN) await builder.computeBlocks(); const tokenAccount = pendingTokenAccount.account; console.log("tokenAccount.publicKey =", tokenAccount.publicKeyString.toString()); // Setting the token account default permissions builder.setInfo( { name: '', description: '', metadata: '', defaultPermission: new KeetaNet.lib.Permissions([ 'ACCESS', // Public token ]), }, { account: tokenAccount }, ) // Minting the token builder.modifyTokenSupply(10_000n, { account: tokenAccount }); builder.modifyTokenBalance(tokenAccount, 10_000n) // Publish the blocks await userClient.publishBuilder(builder); console.log("Token account created and minted.\n"); return tokenAccount; } async function main() { const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); /** * Creating liquidity provider account and token account */ console.log("\nCreating liquidity provider account and token account..."); const liquidityProviderAccount = KeetaNet.lib.Account.fromSeed(seed, 0); const liquidityProviderClient = KeetaNet.UserClient.fromNetwork("test", liquidityProviderAccount); const tokenAccount = await createToken(liquidityProviderClient); console.log("liquidityProviderClient.balances[] =", await liquidityProviderClient.allBalances()); /** * Creating two user accounts (accountA and accountB) * to demonstrate shared storage account creation. */ const accountA = KeetaNet.lib.Account.fromSeed(seed, 1); const accountB = KeetaNet.lib.Account.fromSeed(seed, 2); const userClientA = KeetaNet.UserClient.fromNetwork("test", accountA); const userClientB = KeetaNet.UserClient.fromNetwork("test", accountB); console.log("\nGetting accounts:"); console.log("accountA.publicKey =", accountA.publicKeyString.toString()); console.log("accountB.publicKey =", accountB.publicKeyString.toString()); /** * Checking owned storage accounts */ console.log("\nChecking storage accounts before creation:"); console.log("accountA.storageAccounts[] =", (await userClientA.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); console.log("accountB.storageAccounts[] =", (await userClientB.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); /** * Creating a storage account */ // Initialize the user client builder const builder = userClientA.initBuilder(); // Create a new storage account const pendingStorageAccount = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.STORAGE); // Compute the pending storage account await builder.computeBlocks(); // Get the storage account const storageAccount = pendingStorageAccount.account; console.log("storageAccount.publicKey =", storageAccount.publicKeyString.toString()); // Setting the storage account default permissions builder.setInfo({ name: '', description: '', metadata: '', defaultPermission: new KeetaNet.lib.Permissions([ 'STORAGE_CAN_HOLD', // Allow the storage account to hold any token 'STORAGE_DEPOSIT', // Allow everyone to deposit into the storage account ]) }, { account: storageAccount }); // Until here, only `accountA` has access to the storageAccount, his permission is "OWNER". /** * Adding permission for `accountB` on the `storageAccount` * * Here we can set "ADMIN" or "SEND_ON_BEHALF" permissions for `accountB`. * "ADMIN" would allow `accountB` to manage the storage account, while * "SEND_ON_BEHALF" would allow `accountB` to send tokens from the storage account */ builder.updatePermissions( accountB, new KeetaNet.lib.Permissions(['SEND_ON_BEHALF']), undefined, undefined, { account: storageAccount } ); // Publish the blocks await userClientA.publishBuilder(builder); console.log("Storage account created and permissions updated."); /** * Checking owned storage accounts */ console.log("\nChecking storage accounts after creation:"); console.log("accountA.storageAccounts[] =", (await userClientA.listACLsByPrincipal()).filter(acl => acl.entity.isStorage()).map(acl => acl.entity.publicKeyString.toString())); } ``` -------------------------------- ### Full Code Example: Tokenizing a Real-World Asset Source: https://docs.keeta.com/guides/tokenizing-real-world-assets.md This comprehensive example shows the complete process of creating a non-fungible token (NFT) for a real-world asset on the Keeta test network. It covers account creation, metadata signing, transaction construction, token generation, setting supply to 1, attaching metadata, and publishing the transaction. Ensure you have the '@keetanetwork/keetanet-client' library installed. ```typescript const KeetaNet = require('@keetanetwork/keetanet-client'); const DEMO_SEED = 'D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0'; const ASSET_ID = 'asset://unique-asset-id-001'; async function main() { // 1️⃣ Create two accounts from the seed: // - signer: sends the transaction // - authority: signs the metadata (can be same as signer for demo) const signer = KeetaNet.lib.Account.fromSeed(DEMO_SEED, 0); const authority = KeetaNet.lib.Account.fromSeed(DEMO_SEED, 1); // 2️⃣ Connect to the Keeta test network using the signer account const client = KeetaNet.UserClient.fromNetwork('test', signer); // 3️⃣ Create and sign the asset metadata const assetIdBuffer = Buffer.from(ASSET_ID, 'utf-8'); const signatureBuffer = await authority.sign(assetIdBuffer); const metadata = { asset_id: ASSET_ID, authority: authority.publicKeyString.get(), signature: signatureBuffer.toString('base64') }; const metadataBase64 = Buffer.from(JSON.stringify(metadata)).toString('base64'); // 4️⃣ Start building a transaction const builder = client.initBuilder(); builder.updateAccounts({ signer, account: signer }); // 5️⃣ Generate a new token account (this will be your NFT) const token = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.TOKEN); // 6️⃣ Compute a block to seal the token creation (required before you can modify it) await client.computeBuilderBlocks(builder); // 7️⃣ Set the token supply to 1 — making it a non-fungible token builder.modifyTokenSupply(1n, { account: token.account }); // 8️⃣ Attach the metadata and set default permissions (allow others to hold it) builder.setInfo({ name: 'RWA-DEMO', description: 'Non-Fungible Token representing a real-world asset', metadata: metadataBase64, defaultPermission: new KeetaNet.lib.Permissions(['ACCESS'], []) }, { account: token.account }); // 9️⃣ Compute and publish all blocks to the network await client.computeBuilderBlocks(builder); await client.publishBuilder(builder); // 🔚 Done — log the token's public address console.log('✅ RWA Token created at:', token.account.publicKeyString.get()); } main().catch(console.error); ``` -------------------------------- ### Install KeetaNet SDK Source: https://docs.keeta.com/introduction/start-developing.md Install the KeetaNet SDK package using npm. This command includes TypeScript definitions for enhanced development experience. ```bash npm install @keetanetwork/keetanet-client ``` -------------------------------- ### Main Execution Flow for Storage Account Example Source: https://docs.keeta.com/components/accounts/storage-accounts/single-token-storage-account.md This snippet orchestrates the entire storage account example, including generating a seed, creating a user client, creating a storage account, and updating its permissions to hold the base token. It also includes logging for various stages and states. ```typescript async function main() { const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); const account = KeetaNet.lib.Account.fromSeed(seed, 0); const userClient = KeetaNet.UserClient.fromNetwork("test", account); console.log("account.publicKey =", account.publicKeyString.toString()); console.log("account.storageAccounts[] =", (await userClient.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); /** * Create a new storage account with default permissions allowing deposits. * * This will allow anyone to deposit into the storage account, but won't * allow the storage account to hold any tokens. */ const storageAccount = await createStorageAccount(userClient); console.log("storageAccount.publicKey =", storageAccount.publicKeyString.toString()); console.log("storageAccount.acls[] =", (await userClient.listACLsByEntity({ account: storageAccount })).map(acl => ({ entity: acl.entity.publicKeyString.toString(), principal: acl.principal.publicKeyString.toString(), target: acl.target.publicKeyString.toString(), permissions: acl.permissions.base.flags, }))); console.log(""); console.log("storageAccount.defaultPermission =", (await userClient.state({ account: storageAccount })).info.defaultPermission?.base.flags); console.log(""); // Keeta (KTA) base token account const tokenAccount = userClient.baseToken; /** * Add permission to allow the storage account to hold the base token (Keeta - KTA). */ await userClient.updatePermissions( tokenAccount, new KeetaNet.lib.Permissions(['STORAGE_CAN_HOLD']), undefined, KeetaNet.lib.Block.AdjustMethod.ADD, { account: storageAccount } ) console.log("storageAccount.acls[] =", (await userClient.listACLsByEntity({ account: storageAccount })).map(acl => ({ entity: acl.entity.publicKeyString.toString(), principal: acl.principal.publicKeyString.toString(), target: acl.target.publicKeyString.toString(), permissions: acl.permissions.base.flags, }))); /** * If you try to send tokens that are not the base token (KTA) to the storage account, * it will fail with an error: * "XX does not have required permissions to perform action on YY/undefined -- needs [STORAGE_CAN_HOLD, ACCESS]/[]" * * But if you try to send the base token (KTA) to the storage account, it will succeed. */ } main().then(() => { console.log("Done"); process.exit(0); }).catch((err) => { console.error("Error:", err); process.exit(1); }); ``` -------------------------------- ### Full Code Example for Storage Account Operations Source: https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md This comprehensive example demonstrates various operations related to storage accounts, including listing storage accounts, checking balances before and after deposits, and performing token transfers from both a liquidity provider and a storage account. ```typescript console.log("accountB.storageAccounts[] =",(await userClientB.listACLsByPrincipal()).filter(acl => acl.entity.isStorage()).map(acl => acl.entity.publicKeyString.toString())); /** * Checking balances before deposit */ console.log("\nChecking balances before deposit:"); console.log("accountA.balances[] =", await userClientA.allBalances()); console.log("accountB.balances[] =", await userClientB.allBalances()); console.log("accountA.storageAccount.balances[] =", await userClientA.allBalances({ account: storageAccount })); console.log("accountB.storageAccount.balances[] =", await userClientB.allBalances({ account: storageAccount })); /** * Depositing tokens from the liquidity provider * LP -> SEND 1_000 -> storageAccount * LP -> SEND 5_000 -> accountA */ console.log("\nDepositing tokens from the liquidity provider..."); const builderSend = await liquidityProviderClient.initBuilder(); builderSend.send(storageAccount, 1_000n, tokenAccount); builderSend.send(accountA, 5_000n, tokenAccount); await liquidityProviderClient.publishBuilder(builderSend); /** * Checking balances after deposit */ console.log("\nChecking balances after deposit:"); console.log("accountA.balances[] =", await userClientA.allBalances()); console.log("accountB.balances[] =", await userClientB.allBalances()); console.log("accountA.storageAccount.balances[] =", await userClientA.allBalances({ account: storageAccount })); console.log("accountB.storageAccount.balances[] =", await userClientB.allBalances({ account: storageAccount })); /** * Depositing tokens from the storage account * accountB using storageAccount -> SEND 500 -> accountA * accountB using storageAccount -> SEND 300 -> accountB */ await userClientB.send(accountA, 500n, tokenAccount, undefined, { account: storageAccount }); await userClientB.send(accountB, 300n, tokenAccount, undefined, { account: storageAccount }); console.log("\nChecking balances after accountB sends 500 tokens from storageAccount to accountA:"); console.log("accountA.balances[] =", await userClientA.allBalances()); console.log("accountB.balances[] =", await userClientB.allBalances()); console.log("accountA.storageAccount.balances[] =", await userClientA.allBalances({ account: storageAccount })); console.log("accountB.storageAccount.balances[] =", await userClientB.allBalances({ account: storageAccount })); } main().then(() => { console.log("Done"); process.exit(0); }).catch((err) => { console.error("Error:", err); process.exit(1); }); ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.keeta.com/applications/public-network.md To ask questions about the documentation, perform an HTTP GET request on the current page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/applications/public-network.md?ask= ``` -------------------------------- ### Query Documentation Source: https://docs.keeta.com/components/blocks/operations/modifytokenbalance.md Perform an HTTP GET request to a documentation URL with an 'ask' query parameter to get dynamic answers and relevant excerpts from the documentation. ```http GET https://docs.keeta.com/components/blocks/operations/modifytokenbalance.md?ask= ``` -------------------------------- ### Running an FX Anchor Server Source: https://docs.keeta.com/anchors/overview/anchor-server.md This example demonstrates how to set up and run an FX Anchor Server using the SDK. It includes the necessary imports and basic server configuration. ```typescript import express from "express"; import { AnchorServer } from "@keeta/anchor-server"; const app = express(); const server = new AnchorServer({ app, // ... other configuration options }); server.start(3000).then(() => { console.log("FX Anchor Server started on port 3000"); }); ``` -------------------------------- ### Create and Share Encrypted Container Source: https://docs.keeta.com/anchors/overview/encrypted-containers.md This TypeScript example demonstrates how to create an encrypted container, add recipients, and share it. It requires the Keeta SDK and specific setup for encryption and signing. ```typescript import { EncryptedContainer, Keypair, PublicKey, } from "@keeta/sdk"; async function createAndShareContainer() { // 1. Create a new container const container = new EncryptedContainer(); // 2. Add plaintext data const plaintext = Buffer.from("This is my secret data."); container.addPlaintext(plaintext); // 3. Define recipients (replace with actual public keys) const recipient1 = Keypair.generate().publicKey; const recipient2 = Keypair.generate().publicKey; // 4. Add recipients to the container container.addRecipient(recipient1); container.addRecipient(recipient2); // 5. Optionally sign the container (requires a sender keypair) const senderKeypair = Keypair.generate(); // Replace with your actual keypair await container.sign(senderKeypair); // 6. Serialize the container to ASN.1 format const serializedContainer = container.serialize(); console.log("Serialized Encrypted Container:", serializedContainer.toString('hex')); // In a real application, you would now share 'serializedContainer' // with the recipients. They would then deserialize and decrypt it // using their private keys. } createAndShareContainer().catch(console.error); ``` -------------------------------- ### Query Documentation Source: https://docs.keeta.com/guides/deploying-a-node.md Perform an HTTP GET request to query the documentation dynamically. Replace with your specific query. ```http GET https://docs.keeta.com/guides/deploying-a-node.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/architecture/consensus/vote-stapling.md To get additional information not directly on a page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/architecture/consensus/vote-stapling.md?ask= ``` -------------------------------- ### Initialize KeetaNet SDK in Browser Source: https://docs.keeta.com/introduction/start-developing.md Use the KeetaNet SDK directly in a browser via a script tag. This example demonstrates generating a seed, creating an account, and connecting to the test network. ```html ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/architecture/data-structure.md To ask questions about the documentation, perform an HTTP GET request on the page URL with the 'ask' query parameter. The question should be specific and self-contained. ```HTTP GET https://docs.keeta.com/architecture/data-structure.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/applications Perform an HTTP GET request to query the documentation with a specific question. The response includes a direct answer and relevant excerpts. ```http GET https://docs.keeta.com/applications.md?ask= ``` -------------------------------- ### Account Setup and Initial State Source: https://docs.keeta.com/components/accounts/storage-accounts/single-token-storage-account.md Generates a random seed, creates an account, and initializes a user client connected to the Keeta test network. It also logs the account's public key and lists any existing storage accounts. ```typescript async function main() { const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); const account = KeetaNet.lib.Account.fromSeed(seed, 0); const userClient = KeetaNet.UserClient.fromNetwork("test", account); console.log("account.publicKey =", account.publicKeyString.toString()); console.log("account.storageAccounts[] =", (await userClient.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); } ``` -------------------------------- ### HTTP GET Request to Query Documentation Source: https://docs.keeta.com/components/ledger/get-ledger-history.md Send an HTTP GET request to a documentation URL with the 'ask' query parameter to ask a specific question. The response will provide a direct answer along with relevant excerpts and sources. ```http GET https://docs.keeta.com/components/ledger/get-ledger-history.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/anchors/anchor-types.md To get specific information not readily available on a page, perform an HTTP GET request to the page URL with an 'ask' query parameter. The question should be clear and self-contained. ```http GET https://docs.keeta.com/anchors/anchor-types.md?ask= ``` -------------------------------- ### Querying Documentation with 'ask' Parameter Source: https://docs.keeta.com/scalability/eliminating-mempools.md To get additional information not directly present on a page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/scalability/eliminating-mempools.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/components/certificates.md To ask questions about the documentation, perform an HTTP GET request on the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/components/certificates.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.keeta.com/other-documentation/official-links.md Use this method to ask specific questions about the documentation. The response includes direct answers and relevant excerpts. ```HTTP GET https://docs.keeta.com/other-documentation/official-links.md?ask= ``` -------------------------------- ### Query Documentation Source: https://docs.keeta.com/other-documentation/product-manual.md Perform an HTTP GET request to query the documentation dynamically. The 'ask' parameter should contain a specific, self-contained question in natural language. ```http GET https://docs.keeta.com/other-documentation/product-manual.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.keeta.com/components/blocks/operations.md To get additional information not explicitly present on a page, perform an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/components/blocks/operations.md?ask= ``` -------------------------------- ### Basic FX Client Flow Source: https://docs.keeta.com/anchors/anchor-types/fx-foreign-exchange.md Demonstrates the fundamental steps for a client to perform a foreign exchange conversion using the FX Anchor service. This example covers requesting a quote, verifying it, and constructing the atomic swap transaction. ```typescript import { KeetaClient, AnchorAddress } from "@keeta/sdk"; import { ConversionInput, Quote, QuoteVerificationError } from "@keeta/sdk/anchor/fx"; import { ethers } from "ethers"; async function run() { // Initialize Keeta client const client = new KeetaClient(process.env.KEETA_RPC_URL); // Get FX Anchor address const fxAnchorAddress = await client.getAnchorAddress(AnchorAddress.FX); // Define conversion details const input: ConversionInput = { from: "0x0000000000000000000000000000000000000001", // Example token address to: "0x0000000000000000000000000000000000000002", // Example token address amount: ethers.utils.parseUnits("100", 18), // 100 units of 'from' token affinity: "from", // Amount refers to the 'from' token }; // Request a quote from the FX Anchor const quote = await client.fx.requestQuote(fxAnchorAddress, input); // Verify the quote signature and details const verification = await client.fx.verifyQuote(quote); if (verification === QuoteVerificationError.Ok) { console.log("Quote verified successfully!"); // Construct the atomic swap transaction const tx = await client.fx.buildSwapTx(fxAnchorAddress, quote); // Sign and send the transaction (example using a local signer) const signer = new ethers.Wallet(process.env.PRIVATE_KEY, client.provider); const sentTx = await signer.sendTransaction(tx); const receipt = await sentTx.wait(); console.log("Swap transaction confirmed:", receipt.transactionHash); } else { console.error("Quote verification failed:", verification); } } run().catch(console.error); ``` -------------------------------- ### Query Documentation Page Source: https://docs.keeta.com/applications/private-sub-network.md To ask questions about the documentation, perform an HTTP GET request on the page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/applications/private-sub-network.md?ask= ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.keeta.com/anchors/anchor-types/asset-movement/ethereum-vm-anchors.md This demonstrates how to query the documentation dynamically by appending an 'ask' query parameter to the page URL. This is useful for retrieving specific information not explicitly present on the page. ```http GET https://docs.keeta.com/anchors/anchor-types/asset-movement/ethereum-vm-anchors.md?ask= ``` -------------------------------- ### Initialize Transaction Builder Source: https://docs.keeta.com/components/blocks/operations/modifytokensupply.md Start a new transaction builder instance using the user client. This builder will be used to construct and modify the transaction. ```typescript const builder = userClient.initBuilder() ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/other-documentation Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' query parameter with a specific question in natural language. The response includes the answer and relevant excerpts. ```HTTP GET https://docs.keeta.com/other-documentation.md?ask= ``` -------------------------------- ### Query Documentation API Source: https://docs.keeta.com/introduction/start-developing.md Perform an HTTP GET request to the documentation URL with an 'ask' query parameter to dynamically query the documentation. This is useful for retrieving specific information or clarifications. ```http GET https://docs.keeta.com/introduction/start-developing.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md Perform an HTTP GET request to query the documentation dynamically. Use this when the answer is not explicitly present, you need clarification, or want to retrieve related documentation sections. ```http GET https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md?ask= ``` -------------------------------- ### Query Ledger Documentation Source: https://docs.keeta.com/components/ledger.md To ask questions about this documentation, perform an HTTP GET request on the current page URL with the 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://docs.keeta.com/components/ledger.md?ask= ``` -------------------------------- ### Generate Accounts and Connect to Keeta Test Network Source: https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md Generates a random seed and creates three accounts: a liquidity provider, accountA, and accountB. Each account connects to the Keeta test network. Use this for initial setup. ```typescript async function main() { const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); console.log("seed =", seed); // Create liquidity provider account (token creator) const liquidityProviderAccount = KeetaNet.lib.Account.fromSeed(seed, 0); const liquidityProviderClient = KeetaNet.UserClient.fromNetwork("test", liquidityProviderAccount); // Create two user accounts for shared storage const accountA = KeetaNet.lib.Account.fromSeed(seed, 1); const accountB = KeetaNet.lib.Account.fromSeed(seed, 2); const userClientA = KeetaNet.UserClient.fromNetwork("test", accountA); const userClientB = KeetaNet.UserClient.fromNetwork("test", accountB); console.log("accountA.publicKey =", accountA.publicKeyString.toString()); console.log("accountB.publicKey =", accountB.publicKeyString.toString()); } ``` -------------------------------- ### Create and Configure a Storage Account Source: https://docs.keeta.com/components/accounts/storage-accounts/single-token-storage-account.md This snippet shows how to create a new storage account, set its default permissions to allow deposits, and publish it to the network. It requires an initialized KeetaNet.UserClient. ```typescript import * as KeetaNet from "@keetanetwork/keetanet-client"; async function createStorageAccount(userClient: KeetaNet.UserClient) { // Initialize the user client builder const builder = userClient.initBuilder(); // Create a new storage account const pendingStorageAccount = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.STORAGE); // Compute the pending storage account await builder.computeBlocks(); // Get the storage account const storageAccount = pendingStorageAccount.account; console.log("storageAccount.publicKey =", storageAccount.publicKeyString.toString()); // Setting the storage account default permissions builder.setInfo( { name: '', description: '', metadata: '', defaultPermission: new KeetaNet.lib.Permissions([ 'STORAGE_DEPOSIT', // Allow everyone to deposit into the storage account ]) }, { account: storageAccount } ); // Publish the builder to create the storage account await userClient.publishBuilder(builder); return storageAccount; } ``` -------------------------------- ### Create Storage Account and Set Permissions Source: https://docs.keeta.com/components/accounts/storage-accounts/create-a-storage-account.md Initializes and publishes a new storage account. Sets default permissions for holding and depositing tokens, and grants SEND_ON_BEHALF permission to another account. ```typescript // Check initial storage accounts (should be empty) console.log("\nChecking storage accounts before creation:"); console.log("accountA.storageAccounts[] =", (await userClientA.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); console.log("accountB.storageAccounts[] =", (await userClientB.listACLsByPrincipal()).filter(acl => acl.entity.isStorage())); // Create storage account const builder = userClientA.initBuilder(); const pendingStorageAccount = builder.generateIdentifier(KeetaNet.lib.Account.AccountKeyAlgorithm.STORAGE); await builder.computeBlocks(); const storageAccount = pendingStorageAccount.account; console.log("storageAccount.publicKey =", storageAccount.publicKeyString.toString()); // Set default permissions builder.setInfo({ name: '', description: '', metadata: '', defaultPermission: new KeetaNet.lib.Permissions([ 'STORAGE_CAN_HOLD', // Allow holding any token 'STORAGE_DEPOSIT', // Allow anyone to deposit ]) }, { account: storageAccount }); // Grant SEND_ON_BEHALF permission to accountB builder.updatePermissions( accountB, new KeetaNet.lib.Permissions(['SEND_ON_BEHALF']), undefined, undefined, { account: storageAccount } ); // Publish storage account await userClientA.publishBuilder(builder); console.log("Storage account created and permissions updated."); ``` -------------------------------- ### Get a Token Account Source: https://docs.keeta.com/components/blocks/operations/modifytokensupply.md Retrieve the token account object from its public key string. This is the first step before modifying its supply. ```typescript const tokenAccount = Client.lib.Account.fromPublicKeyString(tokenPublicKey) ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/security Use this method to ask questions about the documentation. The response includes a direct answer and relevant excerpts from the documentation. ```HTTP GET https://docs.keeta.com/security.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.keeta.com/other-documentation/brand-and-press.md Use this method to ask specific questions about the documentation. The response includes a direct answer, relevant excerpts, and sources. This is useful when information is not explicitly present or requires clarification. ```http GET https://docs.keeta.com/other-documentation/brand-and-press.md?ask= ``` -------------------------------- ### Get Public Address from New Account Source: https://docs.keeta.com/introduction/create-your-first-account.md Derives the public Keeta address from a newly generated seed and account. This address is used by others to send you tokens. ```typescript import * as KeetaNet from '@keetanetwork/keetanet-client'; // Generate a secure random seed const seed = KeetaNet.lib.Account.generateRandomSeed({ asString: true }); // Create a new account from the seed (index 0) const account = KeetaNet.lib.Account.fromSeed(seed, 0); // Get the public address const publicKey = account.publicKeyString.toString(); console.log("Your public Keeta address:", publicKey); ``` -------------------------------- ### Using the FX Client Source: https://docs.keeta.com/anchors/overview/anchor-client.md Demonstrates how to use the KeetaAnchor.FX.Client to interact with foreign exchange operations. Ensure you have the necessary Keeta account and have imported the client library. ```typescript import { KeetaAnchor } from "@keeta/keeta-anchor"; // Initialize the FX client const fxClient = new KeetaAnchor.FX.Client(); // Fetch FX rates const rates = await fxClient.getRates({ baseAsset: "USD", quoteAsset: "EUR", }); console.log(rates); // Fetch FX quotes const quotes = await fxClient.getQuotes({ baseAsset: "USD", quoteAsset: "EUR", amount: 1000, }); console.log(quotes); // Execute an FX trade const trade = await fxClient.executeTrade({ baseAsset: "USD", quoteAsset: "EUR", amount: 1000, quoteId: quotes.quoteId, }); console.log(trade); ``` -------------------------------- ### Get Public Address from Existing Account Source: https://docs.keeta.com/introduction/create-your-first-account.md Retrieves the public Keeta address from an existing account using its seed. This is useful if you already have an account and need to share your address. ```typescript const existingSeed = "your existing seed string..."; const account = KeetaNet.lib.Account.fromSeed(existingSeed, 0); const publicKey = account.publicKeyString.toString(); ``` -------------------------------- ### Deploy the Pulumi Stack Source: https://docs.keeta.com/guides/deploying-a-node.md Build necessary binaries and deploy all infrastructure components using the Pulumi stack. This command will prompt for confirmation before proceeding. ```bash make do-deploy ``` -------------------------------- ### Initialize UserClient in NodeJS Source: https://docs.keeta.com/introduction/start-developing.md Create a UserClient instance in Node.js to connect to the Keeta Network. This requires a signer derived from a seed and the network name. ```typescript const signer = KeetaNet.lib.Account.fromSeed(mySeed, 0); const client = KeetaNet.UserClient.fromNetwork('test', signer); ``` -------------------------------- ### Load Keeta SDK and Demo Seed Source: https://docs.keeta.com/components/blocks/operations/send.md Import the KeetaNet SDK and define a demo seed for account generation. In production, store seeds securely and avoid hardcoding. ```typescript const KeetaNet = require('@keetanetwork/keetanet-client'); const DEMO_ACCOUNT_SEED = 'D3M0D3M0...'; ``` -------------------------------- ### Send 1 KTA Transaction Source: https://docs.keeta.com/introduction/send-a-transaction.md This example demonstrates how to send 1 KTA to a specified recipient address using the KeetaNet SDK. Ensure the sending account has sufficient balance before execution. ```typescript /** * Load the KeetaNet Client SDK */ const KeetaNet = require('@keetanetwork/keetanet-client'); /** * This is the fake seed for the demo account, replace with a valid one */ const DEMO_ACCOUNT_SEED = 'D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0D3M0'; async function main() { // Create a signer account from the demo seed (account index 0) const signer_account = KeetaNet.lib.Account.fromSeed(DEMO_ACCOUNT_SEED, 0); console.log('🔑 Signer account:', signer_account.publicKeyString.get()); // Connect to the Keeta test network const client = KeetaNet.UserClient.fromNetwork('test', signer_account); // Start building a transaction const builder = client.initBuilder(); // Define the recipient (the faucet address for testing) const faucet_account = KeetaNet.lib.Account.fromPublicKeyString( 'keeta_aabszsbrqppriqddrkptq5awubshpq3cgsoi4rc624xm6phdt74vo5w7wipwtmi' ); // Add a send operation to the builder: 1 KTA to the faucet address builder.send(faucet_account, 1n, client.baseToken); // Compute the transaction blocks (Keeta breaks operations into blocks) const computed = await client.computeBuilderBlocks(builder); console.log('🧱 Computed blocks:', computed.blocks); // Publish the transaction to the network const transaction = await client.publishBuilder(builder); console.log('✅ Transaction published:', transaction); } main().then( () => process.exit(0), (err) => { console.error('❌ Error:', err); process.exit(1); } ); ``` -------------------------------- ### Initialize Pulumi Stack with KMS Source: https://docs.keeta.com/guides/deploying-a-node.md Initialize a Pulumi stack, specifying a KMS for encrypting secrets. Replace placeholders with your specific project, location, keyring, and key. ```bash pulumi stack init --secrets-provider="gcpkms://projects/

/locations//keyRings//cryptoKeys/" ``` -------------------------------- ### Remove ACCESS Permission using SUBTRACT Method Source: https://docs.keeta.com/components/blocks/operations/updatepermissions.md This example shows how to remove a specific permission, like 'ACCESS', from an account using the `SUBTRACT` method in the `updatePermissions` operation. Ensure the calling account has the necessary rights. ```typescript userClient.updatePermissions( accountToDenyAccess, permissionsToRemove, tokenAccount, Client.lib.Block.AdjustMethod.SUBTRACT, { account: tokenAccount } ); ```