{"id":137,"date":"2025-11-10T02:12:20","date_gmt":"2025-11-09T20:12:20","guid":{"rendered":"https:\/\/stellardns.io\/?page_id=137"},"modified":"2025-11-19T07:49:27","modified_gmt":"2025-11-19T01:49:27","slug":"create-new-accounts","status":"publish","type":"page","link":"https:\/\/stellardns.io\/?page_id=137","title":{"rendered":"Create New Accounts"},"content":{"rendered":"<p class=\"stellar-members-only-notice\">Please connect your Stellar wallet to access this content. <a href=\"\/?page_id=204\/\">Connect Wallet<\/a><\/p>\n\n\n<p class=\"has-black-color has-text-color has-link-color wp-elements-b1ee439d8e96d9396a41adb8e15a188e\">Or send XLM to existing ones! You can fund newly created accounts with xlm you purchase from an exchange like <a href=\"https:\/\/coinbase.com\/join\/CFNX86B?src=referral-link\">Coinbase<\/a>. I purchase and send it out usually right away because I would rather &#8220;hold&#8221; my own and you can too! We all know the banks are going to have to change their models or go out of business SOON! If you have cash, go to MoneyGram and purchase xlm. You can also purchase bitcoin on CashApp, send it to <a href=\"https:\/\/coinbase.com\/join\/CFNX86B?src=referral-link\">Coinbase<\/a> using the &#8216;lightning&#8217; network. It is cheaper to send, and convert it to xlm! Stellar lumens is going to take the market share. It is indeed the least expensive to do transactions and the most versatile! Use the GUI of the Stellar lab below to create new tokens to hold your funds or send to others. Connect to the Mainnet to send real XLM, as the testnet is for testing only. Once you have your XLM and &#8220;FUND&#8221; it by purchasing and sending the xlm you purchase to your new wallet, import your secret key to send your xlm to the donation platform, use it to purchase domains, use it to purchase other tokens, or use it to create other assets! <\/p>\n\n\n<html lang=\"en\">\r\n<head>\r\n    <meta charset=\"UTF-8\">\r\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n    <title>Stellar DNS<\/title>\r\n    <style>\r\n        * {\r\n            margin: 0;\r\n            padding: 0;\r\n            box-sizing: border-box;\r\n        }\r\n\r\n        body {\r\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\r\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\r\n            min-height: 100vh;\r\n            color: #333;\r\n        }\r\n\r\n        .container {\r\n            max-width: 1400px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n        }\r\n\r\n        .header {\r\n            text-align: center;\r\n            margin-bottom: 40px;\r\n            color: white;\r\n        }\r\n\r\n        .header h1 {\r\n            font-size: 3rem;\r\n            margin-bottom: 10px;\r\n            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);\r\n        }\r\n\r\n        .network-switcher {\r\n            display: flex;\r\n            justify-content: center;\r\n            gap: 15px;\r\n            margin: 20px 0;\r\n            flex-wrap: wrap;\r\n        }\r\n\r\n        .network-btn {\r\n            background: rgba(255, 255, 255, 0.1);\r\n            border: 2px solid rgba(255, 255, 255, 0.2);\r\n            border-radius: 15px;\r\n            padding: 15px 25px;\r\n            color: white;\r\n            cursor: pointer;\r\n            transition: all 0.3s ease;\r\n            font-size: 14px;\r\n        }\r\n\r\n        .network-btn.active {\r\n            background: linear-gradient(45deg, #7b68ee, #00d4ff);\r\n            border-color: #00d4ff;\r\n            transform: scale(1.05);\r\n        }\r\n\r\n        .network-btn:hover {\r\n            transform: scale(1.05);\r\n            border-color: #00d4ff;\r\n        }\r\n\r\n        .main-content {\r\n            display: grid;\r\n            grid-template-columns: 1fr 1fr;\r\n            gap: 30px;\r\n            margin-bottom: 40px;\r\n        }\r\n\r\n        .card {\r\n            background: rgba(255,255,255,0.95);\r\n            border-radius: 16px;\r\n            padding: 30px;\r\n            box-shadow: 0 16px 64px rgba(0,0,0,0.1);\r\n            backdrop-filter: blur(20px);\r\n            border: 1px solid rgba(255,255,255,0.2);\r\n        }\r\n\r\n        .card h2 {\r\n            margin-bottom: 20px;\r\n            color: #4a5568;\r\n            font-size: 1.5rem;\r\n        }\r\n\r\n        .form-group {\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .form-group label {\r\n            display: block;\r\n            margin-bottom: 8px;\r\n            font-weight: 600;\r\n            color: #4a5568;\r\n        }\r\n\r\n        .form-group input, .form-group textarea {\r\n            width: 100%;\r\n            padding: 12px 15px;\r\n            border: 2px solid #e2e8f0;\r\n            border-radius: 8px;\r\n            font-size: 1rem;\r\n            transition: all 0.3s ease;\r\n            background: rgba(255,255,255,0.8);\r\n        }\r\n\r\n        .form-group input:focus, .form-group textarea:focus {\r\n            outline: none;\r\n            border-color: #667eea;\r\n            box-shadow: 0 0 0 3px rgba(102,126,234,0.1);\r\n            background: white;\r\n        }\r\n\r\n        .btn {\r\n            background: linear-gradient(135deg, #667eea, #764ba2);\r\n            color: white;\r\n            border: none;\r\n            padding: 14px 28px;\r\n            border-radius: 8px;\r\n            font-size: 1rem;\r\n            font-weight: 600;\r\n            cursor: pointer;\r\n            transition: all 0.3s ease;\r\n            width: 100%;\r\n            margin-top: 10px;\r\n        }\r\n\r\n        .btn:hover {\r\n            transform: translateY(-2px);\r\n            box-shadow: 0 8px 24px rgba(102,126,234,0.3);\r\n        }\r\n\r\n        .btn:disabled {\r\n            opacity: 0.6;\r\n            cursor: not-allowed;\r\n            transform: none;\r\n        }\r\n\r\n        .btn-secondary {\r\n            background: linear-gradient(135deg, #718096, #4a5568);\r\n        }\r\n\r\n        .query-results, .register-results {\r\n            background: #f7fafc;\r\n            border: 2px solid #e2e8f0;\r\n            border-radius: 8px;\r\n            padding: 20px;\r\n            margin-top: 20px;\r\n            font-family: 'Courier New', monospace;\r\n            white-space: pre-wrap;\r\n            max-height: 400px;\r\n            overflow-y: auto;\r\n        }\r\n\r\n        .loading {\r\n            display: inline-block;\r\n            width: 20px;\r\n            height: 20px;\r\n            border: 3px solid rgba(255,255,255,0.3);\r\n            border-radius: 50%;\r\n            border-top-color: white;\r\n            animation: spin 1s ease-in-out infinite;\r\n            margin-right: 10px;\r\n        }\r\n\r\n        .status-message {\r\n            padding: 15px;\r\n            border-radius: 8px;\r\n            margin-top: 15px;\r\n            animation: fadeIn 0.3s ease-out;\r\n        }\r\n\r\n        .status-success {\r\n            background: #d4edda;\r\n            color: #155724;\r\n            border: 1px solid #c3e6cb;\r\n        }\r\n\r\n        .status-error {\r\n            background: #f8d7da;\r\n            color: #721c24;\r\n            border: 1px solid #f5c6cb;\r\n        }\r\n\r\n        .status-warning {\r\n            background: #fff3cd;\r\n            color: #856404;\r\n            border: 1px solid #ffeaa7;\r\n        }\r\n\r\n        .features-grid {\r\n            display: grid;\r\n            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\r\n            gap: 20px;\r\n            margin-top: 40px;\r\n        }\r\n\r\n        .feature-card {\r\n            background: rgba(255,255,255,0.1);\r\n            border: 1px solid rgba(255,255,255,0.2);\r\n            border-radius: 12px;\r\n            padding: 25px;\r\n            text-align: center;\r\n            color: white;\r\n            backdrop-filter: blur(10px);\r\n        }\r\n\r\n        .feature-icon {\r\n            font-size: 2.5rem;\r\n            margin-bottom: 15px;\r\n        }\r\n\r\n        .feature-card h3 {\r\n            margin-bottom: 10px;\r\n            font-size: 1.3rem;\r\n        }\r\n\r\n        .network-status {\r\n            background: rgba(255,255,255,0.1);\r\n            border-radius: 12px;\r\n            padding: 20px;\r\n            margin-bottom: 30px;\r\n            color: white;\r\n            text-align: center;\r\n        }\r\n\r\n        .transaction-explorer {\r\n            background: rgba(255,255,255,0.95);\r\n            border-radius: 16px;\r\n            padding: 30px;\r\n            margin-bottom: 30px;\r\n            box-shadow: 0 16px 64px rgba(0,0,0,0.1);\r\n        }\r\n\r\n        .transaction-item {\r\n            background: rgba(102,126,234,0.1);\r\n            border-radius: 8px;\r\n            padding: 15px;\r\n            margin-bottom: 15px;\r\n            border-left: 4px solid #667eea;\r\n        }\r\n\r\n        .tx-hash {\r\n            font-family: 'Courier New', monospace;\r\n            font-size: 0.9em;\r\n            color: #666;\r\n            word-break: break-all;\r\n        }\r\n\r\n        \/* Wallet Styles *\/\r\n        .wallet-section {\r\n            background: rgba(255,255,255,0.95);\r\n            border-radius: 16px;\r\n            padding: 30px;\r\n            margin-bottom: 30px;\r\n            box-shadow: 0 16px 64px rgba(0,0,0,0.1);\r\n        }\r\n\r\n        .balance-display {\r\n            display: flex;\r\n            align-items: center;\r\n            gap: 10px;\r\n            margin-bottom: 15px;\r\n        }\r\n\r\n        .balance-amount {\r\n            font-size: 1.5em;\r\n            font-weight: bold;\r\n            color: #667eea;\r\n        }\r\n\r\n        .btn-small {\r\n            background: #667eea;\r\n            color: white;\r\n            border: none;\r\n            padding: 8px 12px;\r\n            border-radius: 4px;\r\n            cursor: pointer;\r\n            font-size: 0.8em;\r\n        }\r\n\r\n        .address-input-group {\r\n            display: flex;\r\n            gap: 10px;\r\n            align-items: center;\r\n        }\r\n\r\n        .wallet-actions {\r\n            display: flex;\r\n            gap: 15px;\r\n            flex-wrap: wrap;\r\n        }\r\n\r\n        .wallet-actions .btn {\r\n            width: auto;\r\n            flex: 1;\r\n            min-width: 150px;\r\n        }\r\n\r\n        .btn-primary {\r\n            background: linear-gradient(135deg, #667eea, #764ba2);\r\n        }\r\n\r\n        \/* Modal Styles *\/\r\n        .modal {\r\n            display: none;\r\n            position: fixed;\r\n            top: 0;\r\n            left: 0;\r\n            width: 100%;\r\n            height: 100%;\r\n            background: rgba(0,0,0,0.7);\r\n            z-index: 1000;\r\n        }\r\n\r\n        .modal-content {\r\n            position: absolute;\r\n            top: 50%;\r\n            left: 50%;\r\n            transform: translate(-50%, -50%);\r\n            background: white;\r\n            padding: 30px;\r\n            border-radius: 16px;\r\n            max-width: 500px;\r\n            width: 90%;\r\n        }\r\n\r\n        .close {\r\n            position: absolute;\r\n            top: 10px;\r\n            right: 20px;\r\n            font-size: 30px;\r\n            cursor: pointer;\r\n            color: #999;\r\n        }\r\n\r\n        .modal-actions {\r\n            display: flex;\r\n            gap: 15px;\r\n            margin-top: 20px;\r\n        }\r\n\r\n        .status-bar {\r\n            position: fixed;\r\n            bottom: 0;\r\n            left: 0;\r\n            right: 0;\r\n            background: rgba(102,126,234,0.9);\r\n            color: white;\r\n            padding: 10px 20px;\r\n            text-align: center;\r\n            backdrop-filter: blur(10px);\r\n        }\r\n\r\n        @keyframes fadeIn {\r\n            from { opacity: 0; }\r\n            to { opacity: 1; }\r\n        }\r\n\r\n        @keyframes spin {\r\n            to { transform: rotate(360deg); }\r\n        }\r\n\r\n        @media (max-width: 768px) {\r\n            .main-content {\r\n                grid-template-columns: 1fr;\r\n            }\r\n            \r\n            .header h1 {\r\n                font-size: 2rem;\r\n            }\r\n            \r\n            .wallet-actions {\r\n                flex-direction: column;\r\n            }\r\n        }\r\n    <\/style>\r\n<\/head>\r\n<body>\r\n    <div class=\"container\">\r\n        <div class=\"header\">\r\n            <h1>\ud83c\udf1f Stellar DNS<\/h1>\r\n            <p>Real Blockchain Domain Registry on Stellar Network<\/p>\r\n            <p>Create accounts and fund with test xlm using friendbot!<\/p>\r\n            <div class=\"network-switcher\">\r\n                <button class=\"network-btn\" onclick=\"switchNetwork('testnet')\">\r\n                    \ud83e\uddea Testnet\r\n                <\/button>\r\n                <button class=\"network-btn active\" onclick=\"switchNetwork('mainnet')\">\r\n                    \u2b50 Mainnet\r\n                <\/button>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <div class=\"network-status\" id=\"network-status\">\r\n            <h3>Network Status<\/h3>\r\n            <p id=\"status-text\">Loading network information...<\/p>\r\n        <\/div>\r\n\r\n        <!-- Wallet Section -->\r\n        <div class=\"wallet-section\">\r\n            <h2>\ud83d\udd11 Your Wallet<\/h2>\r\n            <div class=\"balance-display\">\r\n                <span class=\"balance-label\">Balance:<\/span>\r\n                <span class=\"balance-amount\" id=\"balanceAmount\">0.00 XLM<\/span>\r\n                <button id=\"refreshBalance\" class=\"btn-small\">\ud83d\udd04<\/button>\r\n            <\/div>\r\n            <div class=\"form-group\">\r\n                <label>Public Address:<\/label>\r\n                <div class=\"address-input-group\">\r\n                    <input type=\"text\" id=\"publicKey\" placeholder=\"No wallet loaded\">\r\n                    <button id=\"copyAddress\" class=\"btn-small\">Copy<\/button>\r\n                <\/div>\r\n            <\/div>\r\n            <div class=\"wallet-actions\">\r\n                <button id=\"createWallet\" class=\"btn btn-primary\">Create New Wallet<\/button>\r\n                <button id=\"importWallet\" class=\"btn btn-secondary\">Import Wallet<\/button>\r\n                <button id=\"fundTestnet\" class=\"btn btn-secondary\" style=\"display: none;\">Fund Testnet Account<\/button>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <div class=\"main-content\">\r\n            <!-- Signing Weight Management Card -->\r\n            <div class=\"card\">\r\n                <h2>\u2696\ufe0f Signing Weight Management<\/h2>\r\n                <div class=\"status-message status-warning\">\r\n                    <strong>\u26a0\ufe0f Important:<\/strong><br>\r\n                    \u2022 Changes to signing weights affect transaction authorization<br>\r\n                    \u2022 Setting master weight to 0 can lock your account!<br>\r\n                    \u2022 Requires active wallet with XLM balance<br>\r\n                <\/div>\r\n\r\n                <form id=\"signingWeightForm\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"masterWeight\">Master Key Weight (0-255)<\/label>\r\n                        <input type=\"number\" id=\"masterWeight\" min=\"0\" max=\"255\" placeholder=\"Current: Click 'Load Current' to see\">\r\n                    <\/div>\r\n\r\n                    <h3 style=\"margin-top: 20px; margin-bottom: 10px; color: #4a5568;\">Thresholds<\/h3>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"lowThreshold\">Low Threshold (0-255)<\/label>\r\n                        <input type=\"number\" id=\"lowThreshold\" min=\"0\" max=\"255\" placeholder=\"e.g., 1 - for payments\">\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"medThreshold\">Medium Threshold (0-255)<\/label>\r\n                        <input type=\"number\" id=\"medThreshold\" min=\"0\" max=\"255\" placeholder=\"e.g., 5 - for trustlines, offers\">\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"highThreshold\">High Threshold (0-255)<\/label>\r\n                        <input type=\"number\" id=\"highThreshold\" min=\"0\" max=\"255\" placeholder=\"e.g., 10 - for account options\">\r\n                    <\/div>\r\n\r\n                    <h3 style=\"margin-top: 20px; margin-bottom: 10px; color: #4a5568;\">Add Signer (Optional)<\/h3>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"signerKey\">Signer Public Key<\/label>\r\n                        <input type=\"text\" id=\"signerKey\" placeholder=\"GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\">\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"signerWeight\">Signer Weight (0-255)<\/label>\r\n                        <input type=\"number\" id=\"signerWeight\" min=\"0\" max=\"255\" placeholder=\"e.g., 1\">\r\n                    <\/div>\r\n\r\n                    <button type=\"button\" class=\"btn btn-secondary\" onclick=\"loadCurrentWeights()\">\r\n                        Load Current Weights\r\n                    <\/button>\r\n\r\n                    <button type=\"submit\" class=\"btn\" id=\"setWeightsBtn\">\r\n                        Update Signing Weights\r\n                    <\/button>\r\n\r\n                    <button type=\"button\" class=\"btn\" style=\"background: linear-gradient(135deg, #f093fb, #f5576c);\" onclick=\"forceSubmitWeights()\">\r\n                        \ud83d\ude80 Force Submit (Skip Auth Check)\r\n                    <\/button>\r\n                <\/form>\r\n\r\n                <div id=\"weightsResults\" class=\"register-results\" style=\"display: none;\"><\/div>\r\n            <\/div>\r\n\r\n            <!-- Allow Trust Operation Card -->\r\n            <div class=\"card\">\r\n                <h2>\u2705 Allow Trust Operation<\/h2>\r\n                <div class=\"status-message status-warning\">\r\n                    <strong>\u26a0\ufe0f Asset Issuer Only:<\/strong><br>\r\n                    \u2022 This operation is for asset issuers to authorize\/revoke trustlines<br>\r\n                    \u2022 You must be the issuer of the asset<br>\r\n                    \u2022 Requires AUTH_REQUIRED or AUTH_REVOCABLE flags on your account<br>\r\n                    \u2022 Requires active wallet with XLM balance<br>\r\n                <\/div>\r\n\r\n                <form id=\"allowTrustForm\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"trustor\">Trustor Account (who holds the asset)<\/label>\r\n                        <input type=\"text\" id=\"trustor\" placeholder=\"GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" required>\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"assetCode\">Asset Code<\/label>\r\n                        <input type=\"text\" id=\"assetCode\" placeholder=\"e.g., USDC, ATABSC\" maxlength=\"12\" required>\r\n                        <small style=\"color: #666; font-size: 0.9em;\">Max 12 characters<\/small>\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"authorize\">Authorization<\/label>\r\n                        <select id=\"authorize\" class=\"form-control\" style=\"width: 100%; padding: 12px 15px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 1rem;\">\r\n                            <option value=\"true\">\u2705 Authorize (Allow trustline)<\/option>\r\n                            <option value=\"false\">\u274c Revoke (Freeze trustline)<\/option>\r\n                        <\/select>\r\n                    <\/div>\r\n\r\n                    <button type=\"submit\" class=\"btn\" id=\"allowTrustBtn\">\r\n                        Execute Allow Trust\r\n                    <\/button>\r\n\r\n                    <button type=\"button\" class=\"btn btn-secondary\" onclick=\"getInstructionsAllowTrust()\">\r\n                        Get Instructions Only\r\n                    <\/button>\r\n                <\/form>\r\n\r\n                <div id=\"allowTrustResults\" class=\"register-results\" style=\"display: none;\"><\/div>\r\n            <\/div>\r\n\r\n            <!-- Change Trust Operation Card -->\r\n            <div class=\"card\">\r\n                <h2>\ud83e\udd1d Change Trust (Create Trustline)<\/h2>\r\n                <div class=\"status-message status-warning\">\r\n                    <strong>\u2139\ufe0f Create Trustlines to Hold Assets:<\/strong><br>\r\n                    \u2022 Create trustlines to hold USDC, EURC, or any custom asset<br>\r\n                    \u2022 You must create a trustline BEFORE you can receive an asset<br>\r\n                    \u2022 Set a limit to control maximum holdings<br>\r\n                    \u2022 Requires active wallet with XLM balance<br>\r\n                <\/div>\r\n\r\n                <div style=\"margin-bottom: 20px;\">\r\n                    <strong>Quick Add Popular Assets:<\/strong>\r\n                    <div style=\"display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px;\">\r\n                        <button type=\"button\" class=\"btn-small\" onclick=\"setAsset('USDC', 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN')\">\r\n                            \ud83d\udcb5 Circle USDC\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn-small\" onclick=\"setAsset('EURC', 'GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2')\">\r\n                            \ud83d\udcb6 Circle EURC\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn-small\" onclick=\"setAsset('AQUA', 'GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA')\">\r\n                            \ud83c\udf0a Aquarius AQUA\r\n                        <\/button>\r\n                        <button type=\"button\" class=\"btn-small\" onclick=\"setAsset('yXLM', 'GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55')\">\r\n                            \ud83e\ude99 Ultra Stellar yXLM\r\n                        <\/button>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <form id=\"changeTrustForm\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"trustAssetCode\">Asset Code<\/label>\r\n                        <input type=\"text\" id=\"trustAssetCode\" placeholder=\"e.g., USDC, EURC, ATABSC\" maxlength=\"12\" required>\r\n                        <small style=\"color: #666; font-size: 0.9em;\">Max 12 characters<\/small>\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"trustIssuer\">Asset Issuer (Public Key)<\/label>\r\n                        <input type=\"text\" id=\"trustIssuer\" placeholder=\"GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" required>\r\n                    <\/div>\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"trustLimit\">Trust Limit (optional)<\/label>\r\n                        <input type=\"number\" id=\"trustLimit\" placeholder=\"Leave empty for maximum (922,337,203,685.4775807 XLM)\" min=\"0\" step=\"0.0000001\">\r\n                        <small style=\"color: #666; font-size: 0.9em;\">Maximum amount you want to hold. Set to 0 to remove trustline.<\/small>\r\n                    <\/div>\r\n\r\n                    <button type=\"submit\" class=\"btn\" id=\"changeTrustBtn\">\r\n                        Create Trustline\r\n                    <\/button>\r\n\r\n                    <button type=\"button\" class=\"btn btn-secondary\" onclick=\"getInstructionsChangeTrust()\">\r\n                        Get Instructions Only\r\n                    <\/button>\r\n\r\n                    <button type=\"button\" class=\"btn\" style=\"background: linear-gradient(135deg, #fc5c7d, #6a82fb);\" onclick=\"removeTrustline()\">\r\n                        \ud83d\uddd1\ufe0f Remove Trustline (Set Limit to 0)\r\n                    <\/button>\r\n                <\/form>\r\n\r\n                <div id=\"changeTrustResults\" class=\"register-results\" style=\"display: none;\"><\/div>\r\n            <\/div>\r\n\r\n            <!-- DNS Query Card -->\r\n            <div class=\"card\">\r\n                <h2>\ud83d\udd0d Query DNS Records<\/h2>\r\n                <form id=\"queryForm\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"queryAccount\">Stellar Account ID<\/label>\r\n                        <input type=\"text\" id=\"queryAccount\" placeholder=\"GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" required>\r\n                    <\/div>\r\n                    \r\n                    <button type=\"submit\" class=\"btn btn-secondary\">\r\n                        Query Real DNS Records\r\n                    <\/button>\r\n                <\/form>\r\n                \r\n                <div id=\"queryResults\" class=\"query-results\" style=\"display: none;\"><\/div>\r\n            <\/div>\r\n\r\n            <!-- DNS Registration Card -->\r\n            <div class=\"card\">\r\n                <h2>\ud83d\ude80 Test Domain Registration<\/h2>\r\n                <div class=\"status-message status-warning\">\r\n                    <strong>\u26a0\ufe0f Actual registration requires:<\/strong><br>\r\n                    \u2022 Active wallet with XLM balance (cannot use test xlm)<br>\r\n                    \u2022 Domain name (28 char max)<br>\r\n                    \u2022 Valid DNS records<br>\r\n                    \u2022 Switch networks to query live data<br>\r\n                <\/div>\r\n                \r\n                <form id=\"registerForm\">\r\n                    <div class=\"form-group\">\r\n                        <label for=\"domain\">Domain Name<\/label>\r\n                        <input type=\"text\" id=\"domain\" placeholder=\"e.g., mydomain.stellar\" required>\r\n                    <\/div>\r\n                    \r\n                    <div class=\"form-group\">\r\n                        <label for=\"aRecord\">A Record (IPv4)<\/label>\r\n                        <input type=\"text\" id=\"aRecord\" placeholder=\"192.168.1.1\" pattern=\"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\">\r\n                    <\/div>\r\n                    \r\n                    <div class=\"form-group\">\r\n                        <label for=\"mxRecord\">MX Record (optional)<\/label>\r\n                        <input type=\"text\" id=\"mxRecord\" placeholder=\"mail.mydomain.stellar\">\r\n                    <\/div>\r\n                    \r\n                    <div class=\"form-group\">\r\n                        <label for=\"cnameRecord\">CNAME Record (optional)<\/label>\r\n                        <input type=\"text\" id=\"cnameRecord\" placeholder=\"www.mydomain.stellar\">\r\n                    <\/div>\r\n                    \r\n                    <button type=\"submit\" class=\"btn\" id=\"registerBtn\">\r\n                        Test Registration\r\n                    <\/button>\r\n                    \r\n                    <button type=\"button\" class=\"btn btn-secondary\" onclick=\"generateInstructionsOnly()\">\r\n                        Get Instructions Only\r\n                    <\/button>\r\n                   <button type=\"button\" class=\"btn\">\r\n                <a href=\"register_domain.html\" class=\"register-btn\">Live Registration<\/a><\/button>\r\n                <\/form>\r\n                \r\n                <div id=\"registerResults\" class=\"register-results\" style=\"display: none;\"><\/div>\r\n                \r\n            <\/div>\r\n            <\/div>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <!-- Transaction Explorer -->\r\n        <div class=\"transaction-explorer\">\r\n            <h2>\ud83d\udccb Recent DNS Transactions<\/h2>\r\n            <button class=\"btn\" onclick=\"loadRecentDNSTransactions()\">Load Recent DNS Activity<\/button>\r\n            <div id=\"transactionList\"><\/div>\r\n        <\/div>\r\n\r\n        <!-- Features Grid -->\r\n        <div class=\"features-grid\">\r\n            <div class=\"feature-card\">\r\n                <div class=\"feature-icon\">\u26a1<\/div>\r\n                <h3>Real-Time Queries<\/h3>\r\n                <p>Query live DNS records directly from Stellar blockchain<\/p>\r\n            <\/div>\r\n            \r\n            <div class=\"feature-card\">\r\n                <div class=\"feature-icon\">\ud83d\udd12<\/div>\r\n                <h3>Cryptographic Security<\/h3>\r\n                <p>All records secured by Stellar's proven blockchain consensus<\/p>\r\n            <\/div>\r\n            \r\n            <div class=\"feature-card\">\r\n                <div class=\"feature-icon\">\ud83d\udcb0<\/div>\r\n                <h3>Ultra Low Cost<\/h3>\r\n                <p>~$0.00001 per transaction on Stellar mainnet<\/p>\r\n            <\/div>\r\n            \r\n            <div class=\"feature-card\">\r\n                <div class=\"feature-icon\">\ud83c\udf10<\/div>\r\n                <h3>Global Network<\/h3>\r\n                <p>Built on Stellar's worldwide distributed ledger<\/p>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <!-- Import Wallet Modal -->\r\n    <div id=\"importModal\" class=\"modal\">\r\n        <div class=\"modal-content\">\r\n            <span class=\"close\">&times;<\/span>\r\n            <h3>Import Wallet<\/h3>\r\n            <p>Enter your secret key to import an existing wallet:<\/p>\r\n            <input type=\"password\" id=\"secretKeyInput\" placeholder=\"SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" style=\"width: 100%; padding: 10px; margin-top: 10px; border: 2px solid #e2e8f0; border-radius: 8px;\">\r\n            <div class=\"modal-actions\">\r\n                <button id=\"confirmImport\" class=\"btn btn-primary\">Import<\/button>\r\n                <button id=\"cancelImport\" class=\"btn btn-secondary\">Cancel<\/button>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <!-- Status Bar -->\r\n    <div class=\"status-bar\">\r\n        <span id=\"statusMessage\">Ready - Select network and load wallet<\/span>\r\n    <\/div>\r\n\r\n    <!-- Stellar SDK -->\r\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/stellar-sdk\/11.3.0\/stellar-sdk.min.js\"><\/script>\r\n    \r\n    <script>\r\n        let currentNetwork = 'testnet'; \/\/ Start with testnet for safety\r\n        let currentWallet = null;\r\n        let walletBalance = 0;\r\n        \r\n        const NETWORKS = {\r\n            'mainnet': {\r\n                name: 'Stellar Mainnet',\r\n                horizonUrl: 'https:\/\/horizon.stellar.org',\r\n                rpcUrl: 'https:\/\/soroban-mainnet.stellar.org',\r\n                passphrase: StellarSdk.Networks.PUBLIC,\r\n                friendbotUrl: null\r\n            },\r\n            'testnet': {\r\n                name: 'Stellar Testnet', \r\n                horizonUrl: 'https:\/\/horizon-testnet.stellar.org',\r\n                rpcUrl: 'https:\/\/soroban-testnet.stellar.org',\r\n                passphrase: StellarSdk.Networks.TESTNET,\r\n                friendbotUrl: 'https:\/\/friendbot.stellar.org'\r\n            }\r\n        };\r\n\r\n        \/\/ Network switching\r\n        function switchNetwork(networkId) {\r\n            currentNetwork = networkId;\r\n            \r\n            \/\/ Update active button\r\n            document.querySelectorAll('.network-btn').forEach(btn => btn.classList.remove('active'));\r\n            event.target.classList.add('active');\r\n            \r\n            \/\/ Update status\r\n            updateNetworkStatus();\r\n            updateStatusMessage(`Switched to ${NETWORKS[networkId].name}`);\r\n            \r\n            \/\/ Show\/hide testnet funding button\r\n            const fundBtn = document.getElementById('fundTestnet');\r\n            if (networkId === 'testnet') {\r\n                fundBtn.style.display = 'inline-block';\r\n            } else {\r\n                fundBtn.style.display = 'none';\r\n            }\r\n            \r\n            \/\/ Refresh balance if wallet is loaded\r\n            if (currentWallet) {\r\n                refreshBalance();\r\n            }\r\n            \r\n            \/\/ Clear results\r\n            document.getElementById('queryResults').style.display = 'none';\r\n            document.getElementById('registerResults').style.display = 'none';\r\n            document.getElementById('transactionList').innerHTML = '';\r\n        }\r\n\r\n        async function updateNetworkStatus() {\r\n            const network = NETWORKS[currentNetwork];\r\n            const statusDiv = document.getElementById('status-text');\r\n            \r\n            try {\r\n                statusDiv.innerHTML = '\ud83d\udd04 Checking network status...';\r\n                \r\n                const response = await fetch(`${network.horizonUrl}\/`);\r\n                const data = await response.json();\r\n                \r\n                statusDiv.innerHTML = `\r\n                    \u2705 Connected to ${network.name}<br>\r\n                    Latest Ledger: #${data.history_latest_ledger?.toLocaleString() || 'Unknown'}<br>\r\n                    Protocol Version: ${data.current_protocol_version}<br>\r\n                    Network: ${data.network_passphrase}\r\n                `;\r\n                \r\n            } catch (error) {\r\n                statusDiv.innerHTML = `\u274c Failed to connect to ${network.name}<br>Error: ${error.message}`;\r\n            }\r\n        }\r\n\r\n        function updateStatusMessage(message) {\r\n            document.getElementById('statusMessage').textContent = message;\r\n        }\r\n\r\n        \/\/ Wallet Management\r\n        document.getElementById('createWallet').addEventListener('click', createNewWallet);\r\n        document.getElementById('importWallet').addEventListener('click', showImportModal);\r\n        document.getElementById('copyAddress').addEventListener('click', copyAddress);\r\n        document.getElementById('refreshBalance').addEventListener('click', refreshBalance);\r\n        document.getElementById('fundTestnet').addEventListener('click', fundTestnetAccount);\r\n\r\n        function createNewWallet() {\r\n            try {\r\n                const keypair = StellarSdk.Keypair.random();\r\n                currentWallet = keypair;\r\n                \r\n                document.getElementById('publicKey').value = keypair.publicKey();\r\n                updateStatusMessage('New wallet created! Save your secret key securely.');\r\n                \r\n                \/\/ Show secret key in alert (for demo - in production use secure method)\r\n                alert(`\u26a0\ufe0f SAVE THIS SECRET KEY SECURELY:\\n${keypair.secret()}\\n\\nThis is your only copy!`);\r\n                \r\n                refreshBalance();\r\n            } catch (error) {\r\n                updateStatusMessage(`Error creating wallet: ${error.message}`);\r\n            }\r\n        }\r\n\r\n        function showImportModal() {\r\n            document.getElementById('importModal').style.display = 'block';\r\n        }\r\n\r\n        \/\/ Modal event listeners\r\n        document.querySelector('.close').addEventListener('click', () => {\r\n            document.getElementById('importModal').style.display = 'none';\r\n        });\r\n\r\n        document.getElementById('confirmImport').addEventListener('click', () => {\r\n            const secretKey = document.getElementById('secretKeyInput').value.trim();\r\n            if (importWallet(secretKey)) {\r\n                document.getElementById('importModal').style.display = 'none';\r\n                document.getElementById('secretKeyInput').value = '';\r\n            }\r\n        });\r\n\r\n        document.getElementById('cancelImport').addEventListener('click', () => {\r\n            document.getElementById('importModal').style.display = 'none';\r\n            document.getElementById('secretKeyInput').value = '';\r\n        });\r\n\r\n        function importWallet(secretKey) {\r\n            try {\r\n                if (!secretKey || !secretKey.startsWith('S') || secretKey.length !== 56) {\r\n                    alert('Invalid secret key format');\r\n                    return false;\r\n                }\r\n                \r\n                const keypair = StellarSdk.Keypair.fromSecret(secretKey);\r\n                currentWallet = keypair;\r\n                \r\n                document.getElementById('publicKey').value = keypair.publicKey();\r\n                updateStatusMessage('Wallet imported successfully');\r\n                \r\n                refreshBalance();\r\n                return true;\r\n            } catch (error) {\r\n                alert(`Error importing wallet: ${error.message}`);\r\n                return false;\r\n            }\r\n        }\r\n\r\n        async function refreshBalance() {\r\n            if (!currentWallet) {\r\n                document.getElementById('balanceAmount').textContent = '0.00 XLM';\r\n                return;\r\n            }\r\n            \r\n            try {\r\n                const network = NETWORKS[currentNetwork];\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                \r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n                \r\n                const nativeBalance = account.balances.find(balance => balance.asset_type === 'native');\r\n                walletBalance = parseFloat(nativeBalance ? nativeBalance.balance : '0');\r\n                \r\n                document.getElementById('balanceAmount').textContent = `${walletBalance.toFixed(7)} XLM`;\r\n                updateStatusMessage(`Balance updated: ${walletBalance.toFixed(7)} XLM`);\r\n                \r\n            } catch (error) {\r\n                if (error.response?.status === 404) {\r\n                    document.getElementById('balanceAmount').textContent = '0.00 XLM (Not Found)';\r\n                    updateStatusMessage('Account not found - fund with XLM to activate');\r\n                } else {\r\n                    document.getElementById('balanceAmount').textContent = 'Error';\r\n                    updateStatusMessage(`Balance error: ${error.message}`);\r\n                }\r\n            }\r\n        }\r\n\r\n        function copyAddress() {\r\n            const addressField = document.getElementById('publicKey');\r\n            if (addressField.value) {\r\n                addressField.select();\r\n                document.execCommand('copy');\r\n                updateStatusMessage('Address copied to clipboard');\r\n            }\r\n        }\r\n\r\n        async function fundTestnetAccount() {\r\n            if (!currentWallet || currentNetwork !== 'testnet') {\r\n                alert('Load a wallet on testnet first');\r\n                return;\r\n            }\r\n            \r\n            try {\r\n                updateStatusMessage('Requesting testnet XLM...');\r\n                \r\n                const response = await fetch(`https:\/\/friendbot.stellar.org\/?addr=${currentWallet.publicKey()}`);\r\n                \r\n                if (response.ok) {\r\n                    updateStatusMessage('Testnet funding successful!');\r\n                    setTimeout(() => refreshBalance(), 2000);\r\n                } else {\r\n                    throw new Error('Friendbot request failed');\r\n                }\r\n                \r\n            } catch (error) {\r\n                updateStatusMessage(`Funding failed: ${error.message}`);\r\n            }\r\n        }\r\n\r\n        \/\/ DNS Query Implementation (enhanced from your original)\r\n        document.getElementById('queryForm').addEventListener('submit', async function(e) {\r\n            e.preventDefault();\r\n            \r\n            const accountId = document.getElementById('queryAccount').value.trim();\r\n            const resultsDiv = document.getElementById('queryResults');\r\n            \r\n            if (!accountId || !isValidStellarAccount(accountId)) {\r\n                alert('Please enter a valid Stellar account ID (56 characters starting with G)');\r\n                return;\r\n            }\r\n            \r\n            resultsDiv.style.display = 'block';\r\n            resultsDiv.textContent = '\ud83d\udd04 Querying Stellar blockchain for DNS records...';\r\n            \r\n            try {\r\n                const dnsRecords = await queryRealDNSRecords(accountId);\r\n                displayRealQueryResults(dnsRecords, accountId);\r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Error: ${error.message}`;\r\n            }\r\n        });\r\n\r\n        async function queryRealDNSRecords(accountId) {\r\n            const network = NETWORKS[currentNetwork];\r\n            \r\n            try {\r\n                const response = await fetch(`${network.horizonUrl}\/accounts\/${accountId}`);\r\n                if (!response.ok) {\r\n                    throw new Error(`Account not found or inactive`);\r\n                }\r\n                \r\n                const accountData = await response.json();\r\n                \r\n                const txResponse = await fetch(`${network.horizonUrl}\/accounts\/${accountId}\/transactions?order=desc&limit=50`);\r\n                const txData = await txResponse.json();\r\n                \r\n                const dnsRecords = {\r\n                    account: accountData,\r\n                    transactions: txData._embedded?.records || [],\r\n                    dnsData: {},\r\n                    domainName: null,\r\n                    lastUpdated: null,\r\n                    transactionHash: null\r\n                };\r\n                \r\n                \/\/ Parse transactions for DNS memos\r\n                for (const tx of dnsRecords.transactions) {\r\n                    if (tx.memo && tx.memo_type === 'text') {\r\n                        const parsedRecords = parseDNSMemo(tx.memo);\r\n                        if (Object.keys(parsedRecords).length > 0) {\r\n                            dnsRecords.dnsData = parsedRecords;\r\n                            dnsRecords.lastUpdated = tx.created_at;\r\n                            dnsRecords.transactionHash = tx.hash;\r\n                            break;\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                \/\/ Check account data for domain name\r\n                if (accountData.data) {\r\n                    for (const [key, value] of Object.entries(accountData.data)) {\r\n                        if (key === 'dns_domain' || key.includes('domain')) {\r\n                            try {\r\n                                dnsRecords.domainName = atob(value);\r\n                            } catch (e) {\r\n                                dnsRecords.domainName = value;\r\n                            }\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                return dnsRecords;\r\n                \r\n            } catch (error) {\r\n                throw new Error(`Failed to query DNS records: ${error.message}`);\r\n            }\r\n        }\r\n\r\n        function parseDNSMemo(memo) {\r\n            const records = {};\r\n            if (!memo) return records;\r\n            \r\n            const parts = memo.split(';');\r\n            for (const part of parts) {\r\n                if (part.includes(':')) {\r\n                    const [recordType, value] = part.split(':', 2);\r\n                    const type = recordType.trim().toUpperCase();\r\n                    const val = value.trim();\r\n                    \r\n                    if (['A', 'AAAA', 'MX', 'CNAME', 'TXT', 'NS'].includes(type) && val) {\r\n                        records[type] = val;\r\n                    }\r\n                }\r\n            }\r\n            return records;\r\n        }\r\n\r\n        function displayRealQueryResults(dnsRecords, accountId) {\r\n            const resultsDiv = document.getElementById('queryResults');\r\n            \r\n            let output = `=== Real DNS Query Results ===\\n\\n`;\r\n            output += `Account: ${accountId}\\n`;\r\n            output += `Balance: ${getAccountBalance(dnsRecords.account)}\\n`;\r\n            \r\n            if (dnsRecords.domainName) {\r\n                output += `Domain: ${dnsRecords.domainName}\\n`;\r\n            }\r\n            \r\n            output += `\\n--- DNS Records ---\\n`;\r\n            \r\n            if (Object.keys(dnsRecords.dnsData).length > 0) {\r\n                for (const [type, value] of Object.entries(dnsRecords.dnsData)) {\r\n                    output += `${type.padEnd(6)} ${value}\\n`;\r\n                }\r\n                \r\n                output += `\\nLast Updated: ${dnsRecords.lastUpdated}\\n`;\r\n                output += `Transaction: ${dnsRecords.transactionHash}\\n`;\r\n                \r\n                output += `\\n--- Validation ---\\n`;\r\n                for (const [type, value] of Object.entries(dnsRecords.dnsData)) {\r\n                    if (type === 'A') {\r\n                        output += `${type} record: ${validateIPAddress(value) ? '\u2705 Valid' : '\u274c Invalid'} IPv4\\n`;\r\n                    } else {\r\n                        output += `${type} record: \u2705 Present\\n`;\r\n                    }\r\n                }\r\n                \r\n            } else {\r\n                output += `No DNS records found in transaction memos.\\n`;\r\n                output += `\\nTo register DNS records:\\n`;\r\n                output += `1. Use the registration form above\\n`;\r\n                output += `2. Or send a transaction with memo format: \"A:1.2.3.4;MX:mail.domain.com\"\\n`;\r\n            }\r\n            \r\n            output += `\\n--- Recent Activity ---\\n`;\r\n            output += `Total transactions: ${dnsRecords.transactions.length}\\n`;\r\n            output += `Account created: ${dnsRecords.account.last_modified_time}\\n`;\r\n            \r\n            resultsDiv.textContent = output;\r\n        }\r\n\r\n        function getAccountBalance(account) {\r\n            if (!account.balances) return 'Unknown';\r\n            \r\n            for (const balance of account.balances) {\r\n                if (balance.asset_type === 'native') {\r\n                    return `${parseFloat(balance.balance).toFixed(7)} XLM`;\r\n                }\r\n            }\r\n            return 'Unknown';\r\n        }\r\n\r\n        \/\/ DNS Registration Implementation\r\n        document.getElementById('registerForm').addEventListener('submit', async function(e) {\r\n            e.preventDefault();\r\n            \r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n            \r\n            const domain = document.getElementById('domain').value.trim();\r\n            const aRecord = document.getElementById('aRecord').value.trim();\r\n            const mxRecord = document.getElementById('mxRecord').value.trim();\r\n            const cnameRecord = document.getElementById('cnameRecord').value.trim();\r\n            \r\n            if (!domain) {\r\n                alert('Domain name is required');\r\n                return;\r\n            }\r\n            \r\n            const records = {};\r\n            if (aRecord) {\r\n                if (!validateIPAddress(aRecord)) {\r\n                    alert('Invalid IPv4 address format');\r\n                    return;\r\n                }\r\n                records.A = aRecord;\r\n            }\r\n            if (mxRecord) records.MX = mxRecord;\r\n            if (cnameRecord) records.CNAME = cnameRecord;\r\n            \r\n            if (Object.keys(records).length === 0) {\r\n                alert('At least one DNS record is required');\r\n                return;\r\n            }\r\n            \r\n            const resultsDiv = document.getElementById('registerResults');\r\n            resultsDiv.style.display = 'block';\r\n            \r\n            const btn = document.getElementById('registerBtn');\r\n            btn.disabled = true;\r\n            btn.innerHTML = '\ud83d\udd04 Registering on blockchain...';\r\n            \r\n            try {\r\n                const result = await actuallyRegisterDomain(domain, records);\r\n                \r\n                resultsDiv.textContent = `\r\n=== \u2705 REGISTRATION WILL BE SUCCESSFUL! ===\r\n\r\nDomain: ${domain}\r\nAccount: ${currentWallet.publicKey()}\r\nTransaction Hash: ${result.hash}\r\nDNS Memo: ${result.memo}\r\n\r\n\ud83c\udf89 Your domain is now live on the Stellar blockchain!\r\n\r\nNetwork: ${NETWORKS[currentNetwork].name}\r\n\r\n\u23f0 It may take a few seconds to appear in queries.\r\n                `;\r\n                \r\n                document.getElementById('registerForm').reset();\r\n                refreshBalance();\r\n                \r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Registration Failed: ${error.message}`;\r\n            } finally {\r\n                btn.disabled = false;\r\n                btn.innerHTML = 'Register Domain Live';\r\n            }\r\n        });\r\n\r\n        async function actuallyRegisterDomain(domain, records) {\r\n            try {\r\n                const network = NETWORKS[currentNetwork];\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                \r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n                \r\n                const memoparts = [];\r\n                for (const [type, value] of Object.entries(records)) {\r\n                    memoparts.push(`${type}:${value}`);\r\n                }\r\n                const memo = memoparts.join(';');\r\n                \r\n                if (new TextEncoder().encode(memo).length > 28) {\r\n                    throw new Error('DNS memo too long (max 28 bytes)');\r\n                }\r\n                \r\n                const transaction = new StellarSdk.TransactionBuilder(account, {\r\n                    fee: StellarSdk.BASE_FEE,\r\n                    networkPassphrase: network.passphrase,\r\n                })\r\n                .addOperation(StellarSdk.Operation.manageData({\r\n                    name: \"dns_domain\",\r\n                    value: domain\r\n                }))\r\n                .addMemo(StellarSdk.Memo.id(memo))\r\n                .setTimeout(180)\r\n                .build();\r\n                \r\n                transaction.sign(currentWallet);\r\n                \r\n                const result = await server.submitTransaction(transaction);\r\n                \r\n                return {\r\n                    success: true,\r\n                    hash: result.hash,\r\n                    memo: memo\r\n                };\r\n                \r\n            } catch (error) {\r\n                console.error('Registration error:', error);\r\n                throw new Error(`Registration failed: ${error.message}`);\r\n            }\r\n        }\r\n\r\n        function generateInstructionsOnly() {\r\n            const domain = document.getElementById('domain').value.trim();\r\n            const aRecord = document.getElementById('aRecord').value.trim();\r\n            const mxRecord = document.getElementById('mxRecord').value.trim();\r\n            const cnameRecord = document.getElementById('cnameRecord').value.trim();\r\n            \r\n            if (!domain) {\r\n                alert('Domain name is required');\r\n                return;\r\n            }\r\n            \r\n            const records = {};\r\n            if (aRecord) records.A = aRecord;\r\n            if (mxRecord) records.MX = mxRecord;\r\n            if (cnameRecord) records.CNAME = cnameRecord;\r\n            \r\n            if (Object.keys(records).length === 0) {\r\n                alert('At least one DNS record is required');\r\n                return;\r\n            }\r\n            \r\n            const memoparts = [];\r\n            for (const [type, value] of Object.entries(records)) {\r\n                memoparts.push(`${type}:${value}`);\r\n            }\r\n            const memo = memoparts.join(';');\r\n            \r\n            const memoBytes = new TextEncoder().encode(memo).length;\r\n            \r\n            const resultsDiv = document.getElementById('registerResults');\r\n            resultsDiv.style.display = 'block';\r\n            \r\n            let output = `=== DNS Registration Instructions ===\\n\\n`;\r\n            output += `Domain: ${domain}\\n`;\r\n            output += `DNS Memo: ${memo}\\n`;\r\n            output += `Memo Size: ${memoBytes} bytes ${memoBytes > 28 ? '\u274c (Too long!)' : '\u2705'}\\n\\n`;\r\n            \r\n            if (memoBytes > 28) {\r\n                output += `ERROR: Memo too long! Please shorten your records.\\n\\n`;\r\n            }\r\n            \r\n            output += `--- Registration Methods ---\\n\\n`;\r\n            \r\n            output += `Method 1: Using This Interface\\n`;\r\n            output += `1. Load a wallet with XLM\\n`;\r\n            output += `2. Fill in the form above\\n`;\r\n            output += `3. Click \"Register Domain Live\"\\n\\n`;\r\n            \r\n            output += `Method 2: Using Stellar Laboratory\\n`;\r\n            output += `1. Go to https:\/\/laboratory.stellar.org\\n`;\r\n            output += `2. Build transaction with \"Manage Data\" operation\\n`;\r\n            output += `3. Set memo to: \"${memo}\"\\n`;\r\n            output += `4. Sign and submit\\n\\n`;\r\n            \r\n            output += `Cost: ~${StellarSdk.BASE_FEE \/ 10000000} XLM on ${NETWORKS[currentNetwork].name}\\n`;\r\n            \r\n            resultsDiv.textContent = output;\r\n        }\r\n\r\n        async function loadRecentDNSTransactions() {\r\n            const network = NETWORKS[currentNetwork];\r\n            const listDiv = document.getElementById('transactionList');\r\n            \r\n            listDiv.innerHTML = '<div class=\"loading\"><\/div> Loading recent DNS transactions...';\r\n            \r\n            try {\r\n                const response = await fetch(`${network.horizonUrl}\/transactions?order=desc&limit=100`);\r\n                const data = await response.json();\r\n                \r\n                const dnsTransactions = [];\r\n                \r\n                for (const tx of data._embedded.records) {\r\n                    if (tx.memo && tx.memo_type === 'text') {\r\n                        const records = parseDNSMemo(tx.memo);\r\n                        if (Object.keys(records).length > 0) {\r\n                            dnsTransactions.push({\r\n                                ...tx,\r\n                                dnsRecords: records\r\n                            });\r\n                        }\r\n                    }\r\n                }\r\n                \r\n                if (dnsTransactions.length === 0) {\r\n                    listDiv.innerHTML = '<p>No recent DNS transactions found in the last 100 transactions.<\/p>';\r\n                    return;\r\n                }\r\n                \r\n                listDiv.innerHTML = `\r\n                    <h3>Found ${dnsTransactions.length} DNS transactions:<\/h3>\r\n                    ${dnsTransactions.map(tx => `\r\n                        <div class=\"transaction-item\">\r\n                            <strong>\ud83d\udcdd DNS Transaction<\/strong><br>\r\n                            <strong>Account:<\/strong> ${tx.source_account.substring(0,12)}...<br>\r\n                            <strong>Records:<\/strong> ${Object.entries(tx.dnsRecords).map(([k,v]) => `${k}:${v}`).join(', ')}<br>\r\n                            <strong>Date:<\/strong> ${new Date(tx.created_at).toLocaleString()}<br>\r\n                            <div class=\"tx-hash\">Hash: ${tx.hash}<\/div>\r\n                        <\/div>\r\n                    `).join('')}\r\n                `;\r\n                \r\n            } catch (error) {\r\n                listDiv.innerHTML = `<p>\u274c Error loading transactions: ${error.message}<\/p>`;\r\n            }\r\n        }\r\n\r\n        \/\/ Utility functions\r\n        function validateIPAddress(ip) {\r\n            const pattern = \/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$\/;\r\n            return pattern.test(ip);\r\n        }\r\n\r\n        function isValidStellarAccount(accountId) {\r\n            return accountId && accountId.length === 56 && accountId.startsWith('G');\r\n        }\r\n\r\n        \/\/ Signing Weight Management\r\n        document.getElementById('signingWeightForm').addEventListener('submit', async function(e) {\r\n            e.preventDefault();\r\n\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            const masterWeight = document.getElementById('masterWeight').value;\r\n            const lowThreshold = document.getElementById('lowThreshold').value;\r\n            const medThreshold = document.getElementById('medThreshold').value;\r\n            const highThreshold = document.getElementById('highThreshold').value;\r\n            const signerKey = document.getElementById('signerKey').value.trim();\r\n            const signerWeight = document.getElementById('signerWeight').value;\r\n\r\n            \/\/ Validate at least one field is filled\r\n            if (!masterWeight && !lowThreshold && !medThreshold && !highThreshold && !signerKey) {\r\n                alert('Please fill in at least one field to update');\r\n                return;\r\n            }\r\n\r\n            \/\/ Validate threshold hierarchy (low <= medium <= high)\r\n            if (lowThreshold && medThreshold && parseInt(lowThreshold) > parseInt(medThreshold)) {\r\n                alert('Low threshold must be <= Medium threshold');\r\n                return;\r\n            }\r\n            if (medThreshold && highThreshold && parseInt(medThreshold) > parseInt(highThreshold)) {\r\n                alert('Medium threshold must be <= High threshold');\r\n                return;\r\n            }\r\n            if (lowThreshold && highThreshold && parseInt(lowThreshold) > parseInt(highThreshold)) {\r\n                alert('Low threshold must be <= High threshold');\r\n                return;\r\n            }\r\n\r\n            \/\/ Validate weight ranges\r\n            if (masterWeight && (parseInt(masterWeight) < 0 || parseInt(masterWeight) > 255)) {\r\n                alert('Master weight must be between 0 and 255');\r\n                return;\r\n            }\r\n\r\n            \/\/ Warning if setting master weight to 0\r\n            if (masterWeight && parseInt(masterWeight) === 0) {\r\n                if (!confirm('\u26a0\ufe0f WARNING: Setting master weight to 0 will disable this key!\\n\\nMake sure you have other signers configured or you will lose access to your account.\\n\\nContinue?')) {\r\n                    return;\r\n                }\r\n            }\r\n\r\n            \/\/ Validate signer if provided\r\n            if (signerKey && !isValidStellarAccount(signerKey)) {\r\n                alert('Invalid signer public key format');\r\n                return;\r\n            }\r\n\r\n            if (signerKey && !signerWeight) {\r\n                alert('Please provide a weight for the signer');\r\n                return;\r\n            }\r\n\r\n            if (signerWeight && (parseInt(signerWeight) < 0 || parseInt(signerWeight) > 255)) {\r\n                alert('Signer weight must be between 0 and 255');\r\n                return;\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('weightsResults');\r\n            resultsDiv.style.display = 'block';\r\n\r\n            const btn = document.getElementById('setWeightsBtn');\r\n            btn.disabled = true;\r\n            btn.innerHTML = '\ud83d\udd04 Updating signing weights...';\r\n\r\n            try {\r\n                const result = await updateSigningWeights({\r\n                    masterWeight: masterWeight ? parseInt(masterWeight) : undefined,\r\n                    lowThreshold: lowThreshold ? parseInt(lowThreshold) : undefined,\r\n                    medThreshold: medThreshold ? parseInt(medThreshold) : undefined,\r\n                    highThreshold: highThreshold ? parseInt(highThreshold) : undefined,\r\n                    signer: signerKey ? {\r\n                        key: signerKey,\r\n                        weight: parseInt(signerWeight)\r\n                    } : undefined\r\n                });\r\n\r\n                resultsDiv.textContent = `\r\n=== \u2705 SIGNING WEIGHTS UPDATED SUCCESSFULLY! ===\r\n\r\nAccount: ${currentWallet.publicKey()}\r\nTransaction Hash: ${result.hash}\r\n\r\nChanges Applied:\r\n${masterWeight ? `\u2022 Master Weight: ${masterWeight}\\n` : ''}${lowThreshold ? `\u2022 Low Threshold: ${lowThreshold}\\n` : ''}${medThreshold ? `\u2022 Medium Threshold: ${medThreshold}\\n` : ''}${highThreshold ? `\u2022 High Threshold: ${highThreshold}\\n` : ''}${signerKey ? `\u2022 Added Signer: ${signerKey.substring(0, 12)}... (weight: ${signerWeight})\\n` : ''}\r\nNetwork: ${NETWORKS[currentNetwork].name}\r\n\r\n\ud83c\udf89 Your account signing configuration has been updated!\r\n                `;\r\n\r\n                document.getElementById('signingWeightForm').reset();\r\n                refreshBalance();\r\n\r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Update Failed: ${error.message}`;\r\n            } finally {\r\n                btn.disabled = false;\r\n                btn.innerHTML = 'Update Signing Weights';\r\n            }\r\n        });\r\n\r\n        async function loadCurrentWeights() {\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            try {\r\n                updateStatusMessage('Loading current signing weights...');\r\n\r\n                const network = NETWORKS[currentNetwork];\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n\r\n                \/\/ Populate form with current values\r\n                document.getElementById('masterWeight').value = account.signers.find(s => s.key === currentWallet.publicKey())?.weight || 1;\r\n                document.getElementById('lowThreshold').value = account.thresholds.low_threshold;\r\n                document.getElementById('medThreshold').value = account.thresholds.med_threshold;\r\n                document.getElementById('highThreshold').value = account.thresholds.high_threshold;\r\n\r\n                \/\/ Show results\r\n                const resultsDiv = document.getElementById('weightsResults');\r\n                resultsDiv.style.display = 'block';\r\n\r\n                let output = `=== Current Signing Configuration ===\\n\\n`;\r\n                output += `Account: ${currentWallet.publicKey()}\\n\\n`;\r\n                output += `Master Key Weight: ${account.signers.find(s => s.key === currentWallet.publicKey())?.weight || 1}\\n\\n`;\r\n                output += `Thresholds:\\n`;\r\n                output += `  Low:    ${account.thresholds.low_threshold}\\n`;\r\n                output += `  Medium: ${account.thresholds.med_threshold}\\n`;\r\n                output += `  High:   ${account.thresholds.high_threshold}\\n\\n`;\r\n\r\n                if (account.signers.length > 1) {\r\n                    output += `Additional Signers (${account.signers.length - 1}):\\n`;\r\n                    account.signers.forEach(signer => {\r\n                        if (signer.key !== currentWallet.publicKey()) {\r\n                            output += `  ${signer.key.substring(0, 12)}... (weight: ${signer.weight})\\n`;\r\n                        }\r\n                    });\r\n                } else {\r\n                    output += `Additional Signers: None\\n`;\r\n                }\r\n\r\n                resultsDiv.textContent = output;\r\n                updateStatusMessage('Current weights loaded successfully');\r\n\r\n            } catch (error) {\r\n                if (error.response?.status === 404) {\r\n                    alert('Account not found - fund with XLM to activate');\r\n                } else {\r\n                    alert(`Error loading weights: ${error.message}`);\r\n                }\r\n                updateStatusMessage(`Error: ${error.message}`);\r\n            }\r\n        }\r\n\r\n        async function forceSubmitWeights() {\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            const masterWeight = document.getElementById('masterWeight').value;\r\n            const lowThreshold = document.getElementById('lowThreshold').value;\r\n            const medThreshold = document.getElementById('medThreshold').value;\r\n            const highThreshold = document.getElementById('highThreshold').value;\r\n            const signerKey = document.getElementById('signerKey').value.trim();\r\n            const signerWeight = document.getElementById('signerWeight').value;\r\n\r\n            if (!masterWeight && !lowThreshold && !medThreshold && !highThreshold && !signerKey) {\r\n                alert('Please fill in at least one field to update');\r\n                return;\r\n            }\r\n\r\n            if (!confirm('\u26a0\ufe0f FORCE SUBMIT WARNING\\n\\nThis will skip the authorization check and try to submit anyway.\\n\\nThis might work if you are raising your master weight in the same transaction.\\n\\nContinue?')) {\r\n                return;\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('weightsResults');\r\n            resultsDiv.style.display = 'block';\r\n            resultsDiv.textContent = '\ud83d\ude80 Force submitting transaction (skipping auth check)...';\r\n\r\n            try {\r\n                const result = await updateSigningWeights({\r\n                    masterWeight: masterWeight ? parseInt(masterWeight) : undefined,\r\n                    lowThreshold: lowThreshold ? parseInt(lowThreshold) : undefined,\r\n                    medThreshold: medThreshold ? parseInt(medThreshold) : undefined,\r\n                    highThreshold: highThreshold ? parseInt(highThreshold) : undefined,\r\n                    signer: signerKey ? {\r\n                        key: signerKey,\r\n                        weight: parseInt(signerWeight)\r\n                    } : undefined\r\n                }, true); \/\/ true = skip auth check\r\n\r\n                resultsDiv.textContent = `\r\n=== \u2705 FORCE SUBMIT SUCCESSFUL! ===\r\n\r\nAccount: ${currentWallet.publicKey()}\r\nTransaction Hash: ${result.hash}\r\n\r\nChanges Applied:\r\n${masterWeight ? `\u2022 Master Weight: ${masterWeight}\\n` : ''}${lowThreshold ? `\u2022 Low Threshold: ${lowThreshold}\\n` : ''}${medThreshold ? `\u2022 Medium Threshold: ${medThreshold}\\n` : ''}${highThreshold ? `\u2022 High Threshold: ${highThreshold}\\n` : ''}${signerKey ? `\u2022 Added Signer: ${signerKey.substring(0, 12)}... (weight: ${signerWeight})\\n` : ''}\r\nNetwork: ${NETWORKS[currentNetwork].name}\r\n\r\n\ud83c\udf89 It worked! Your signing configuration has been updated!\r\n                `;\r\n\r\n                document.getElementById('signingWeightForm').reset();\r\n                refreshBalance();\r\n\r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Force Submit Failed: ${error.message}\\n\\nThe blockchain rejected the transaction. You may need to use Stellar Laboratory or get help from another signer.`;\r\n            }\r\n        }\r\n\r\n        async function updateSigningWeights(options, skipAuthCheck = false) {\r\n            try {\r\n                const network = NETWORKS[currentNetwork];\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n\r\n                \/\/ Check authorization - setOptions requires HIGH threshold\r\n                if (!skipAuthCheck) {\r\n                    const masterSigner = account.signers.find(s => s.key === currentWallet.publicKey());\r\n                    const masterWeight = masterSigner ? masterSigner.weight : 0;\r\n                    const highThreshold = account.thresholds.high_threshold;\r\n\r\n                    console.log('Authorization check:', {\r\n                        masterWeight,\r\n                        highThreshold,\r\n                        totalSignerWeight: account.signers.reduce((sum, s) => sum + s.weight, 0)\r\n                    });\r\n\r\n                    if (masterWeight < highThreshold) {\r\n                        throw new Error(\r\n                            `Insufficient authorization!\\n\\n` +\r\n                            `Your master weight: ${masterWeight}\\n` +\r\n                            `High threshold required: ${highThreshold}\\n\\n` +\r\n                            `You need to add additional signers or have someone with sufficient weight sign this transaction.\\n\\n` +\r\n                            `Current signers:\\n${account.signers.map(s => `  ${s.key.substring(0, 12)}... (weight: ${s.weight})`).join('\\n')}`\r\n                        );\r\n                    }\r\n                }\r\n\r\n                \/\/ Build operation parameters - only include defined values\r\n                const setOptionsParams = {};\r\n\r\n                \/\/ Add thresholds\r\n                if (options.lowThreshold !== undefined) {\r\n                    setOptionsParams.lowThreshold = options.lowThreshold;\r\n                }\r\n                if (options.medThreshold !== undefined) {\r\n                    setOptionsParams.medThreshold = options.medThreshold;\r\n                }\r\n                if (options.highThreshold !== undefined) {\r\n                    setOptionsParams.highThreshold = options.highThreshold;\r\n                }\r\n\r\n                \/\/ Add master weight\r\n                if (options.masterWeight !== undefined) {\r\n                    setOptionsParams.masterWeight = options.masterWeight;\r\n                }\r\n\r\n                \/\/ Add signer with correct format\r\n                if (options.signer && options.signer.key) {\r\n                    setOptionsParams.signer = {\r\n                        ed25519PublicKey: options.signer.key,\r\n                        weight: options.signer.weight\r\n                    };\r\n                }\r\n\r\n                console.log('SetOptions params:', setOptionsParams);\r\n\r\n                \/\/ Build transaction\r\n                const transaction = new StellarSdk.TransactionBuilder(account, {\r\n                    fee: StellarSdk.BASE_FEE,\r\n                    networkPassphrase: network.passphrase,\r\n                })\r\n                .addOperation(StellarSdk.Operation.setOptions(setOptionsParams))\r\n                .setTimeout(180)\r\n                .build();\r\n\r\n                \/\/ Sign transaction\r\n                transaction.sign(currentWallet);\r\n\r\n                \/\/ Submit to network\r\n                const result = await server.submitTransaction(transaction);\r\n\r\n                return {\r\n                    success: true,\r\n                    hash: result.hash\r\n                };\r\n\r\n            } catch (error) {\r\n                console.error('Full error:', error);\r\n\r\n                \/\/ Extract detailed error message from Horizon\r\n                let errorMsg = error.message;\r\n\r\n                if (error.response && error.response.data) {\r\n                    console.error('Horizon error details:', error.response.data);\r\n\r\n                    if (error.response.data.extras && error.response.data.extras.result_codes) {\r\n                        const codes = error.response.data.extras.result_codes;\r\n                        errorMsg = `Transaction failed: ${codes.transaction || ''} - Operations: ${JSON.stringify(codes.operations || [])}`;\r\n                    } else if (error.response.data.title) {\r\n                        errorMsg = error.response.data.title;\r\n                    }\r\n                }\r\n\r\n                throw new Error(errorMsg);\r\n            }\r\n        }\r\n\r\n        \/\/ Allow Trust Operation\r\n        document.getElementById('allowTrustForm').addEventListener('submit', async function(e) {\r\n            e.preventDefault();\r\n\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            const trustor = document.getElementById('trustor').value.trim();\r\n            const assetCode = document.getElementById('assetCode').value.trim().toUpperCase();\r\n            const authorize = document.getElementById('authorize').value === 'true';\r\n\r\n            \/\/ Validate trustor account\r\n            if (!isValidStellarAccount(trustor)) {\r\n                alert('Invalid trustor account address');\r\n                return;\r\n            }\r\n\r\n            \/\/ Validate asset code\r\n            if (!assetCode || assetCode.length > 12) {\r\n                alert('Asset code must be 1-12 characters');\r\n                return;\r\n            }\r\n\r\n            \/\/ Warn about revoking\r\n            if (!authorize) {\r\n                if (!confirm(`\u26a0\ufe0f You are about to REVOKE authorization for ${assetCode} trustline.\\n\\nThis will freeze the trustline and prevent the trustor from transacting this asset.\\n\\nContinue?`)) {\r\n                    return;\r\n                }\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('allowTrustResults');\r\n            resultsDiv.style.display = 'block';\r\n\r\n            const btn = document.getElementById('allowTrustBtn');\r\n            btn.disabled = true;\r\n            btn.innerHTML = '\ud83d\udd04 Executing Allow Trust...';\r\n\r\n            try {\r\n                const result = await executeAllowTrust(trustor, assetCode, authorize);\r\n\r\n                resultsDiv.textContent = `\r\n=== \u2705 ALLOW TRUST SUCCESSFUL! ===\r\n\r\nAsset Issuer: ${currentWallet.publicKey()}\r\nTrustor: ${trustor}\r\nAsset: ${assetCode}\r\nAction: ${authorize ? 'AUTHORIZED \u2705' : 'REVOKED \u274c'}\r\n\r\nTransaction Hash: ${result.hash}\r\n\r\nNetwork: ${NETWORKS[currentNetwork].name}\r\n\r\n${authorize ? '\ud83c\udf89 The trustline has been authorized! The trustor can now hold and transact this asset.' : '\u26a0\ufe0f The trustline has been revoked. The trustor cannot transact this asset until re-authorized.'}\r\n                `;\r\n\r\n                document.getElementById('allowTrustForm').reset();\r\n                refreshBalance();\r\n\r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Allow Trust Failed: ${error.message}`;\r\n            } finally {\r\n                btn.disabled = false;\r\n                btn.innerHTML = 'Execute Allow Trust';\r\n            }\r\n        });\r\n\r\n        async function executeAllowTrust(trustor, assetCode, authorize) {\r\n            try {\r\n                const network = NETWORKS[currentNetwork];\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n\r\n                \/\/ Verify account has proper flags set\r\n                const flags = account.flags;\r\n                console.log('Account flags:', flags);\r\n\r\n                if (!flags.auth_required && !flags.auth_revocable) {\r\n                    throw new Error(\r\n                        'Your account must have AUTH_REQUIRED or AUTH_REVOCABLE flag set to use allowTrust.\\n\\n' +\r\n                        'Set these flags using the Set Options operation first.'\r\n                    );\r\n                }\r\n\r\n                \/\/ Build the allowTrust operation\r\n                const allowTrustOp = StellarSdk.Operation.allowTrust({\r\n                    trustor: trustor,\r\n                    assetCode: assetCode,\r\n                    authorize: authorize\r\n                });\r\n\r\n                \/\/ Build transaction\r\n                const transaction = new StellarSdk.TransactionBuilder(account, {\r\n                    fee: StellarSdk.BASE_FEE,\r\n                    networkPassphrase: network.passphrase,\r\n                })\r\n                .addOperation(allowTrustOp)\r\n                .setTimeout(180)\r\n                .build();\r\n\r\n                \/\/ Sign transaction\r\n                transaction.sign(currentWallet);\r\n\r\n                \/\/ Submit to network\r\n                const result = await server.submitTransaction(transaction);\r\n\r\n                return {\r\n                    success: true,\r\n                    hash: result.hash\r\n                };\r\n\r\n            } catch (error) {\r\n                console.error('Full error:', error);\r\n\r\n                \/\/ Extract detailed error message from Horizon\r\n                let errorMsg = error.message;\r\n\r\n                if (error.response && error.response.data) {\r\n                    console.error('Horizon error details:', error.response.data);\r\n\r\n                    if (error.response.data.extras && error.response.data.extras.result_codes) {\r\n                        const codes = error.response.data.extras.result_codes;\r\n\r\n                        \/\/ Provide helpful error messages\r\n                        if (codes.operations && codes.operations.includes('op_not_authorized')) {\r\n                            errorMsg = 'Not authorized: You are not the issuer of this asset';\r\n                        } else if (codes.operations && codes.operations.includes('op_no_trustline')) {\r\n                            errorMsg = `No trustline found: The trustor (${trustor}) has not established a trustline for ${assetCode}`;\r\n                        } else if (codes.operations && codes.operations.includes('op_trust_not_required')) {\r\n                            errorMsg = 'Trust not required: Your account does not have AUTH_REQUIRED or AUTH_REVOCABLE flags set';\r\n                        } else {\r\n                            errorMsg = `Transaction failed: ${codes.transaction || ''} - Operations: ${JSON.stringify(codes.operations || [])}`;\r\n                        }\r\n                    } else if (error.response.data.title) {\r\n                        errorMsg = error.response.data.title;\r\n                    }\r\n                }\r\n\r\n                throw new Error(errorMsg);\r\n            }\r\n        }\r\n\r\n        function getInstructionsAllowTrust() {\r\n            const trustor = document.getElementById('trustor').value.trim();\r\n            const assetCode = document.getElementById('assetCode').value.trim().toUpperCase();\r\n            const authorize = document.getElementById('authorize').value === 'true';\r\n\r\n            if (!trustor || !assetCode) {\r\n                alert('Please fill in trustor account and asset code');\r\n                return;\r\n            }\r\n\r\n            if (!isValidStellarAccount(trustor)) {\r\n                alert('Invalid trustor account address');\r\n                return;\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('allowTrustResults');\r\n            resultsDiv.style.display = 'block';\r\n\r\n            let output = `=== Allow Trust Instructions ===\\n\\n`;\r\n            output += `Issuer (You): ${currentWallet ? currentWallet.publicKey() : '[Load wallet first]'}\\n`;\r\n            output += `Trustor: ${trustor}\\n`;\r\n            output += `Asset: ${assetCode}\\n`;\r\n            output += `Action: ${authorize ? 'AUTHORIZE \u2705' : 'REVOKE \u274c'}\\n\\n`;\r\n\r\n            output += `--- Prerequisites ---\\n\\n`;\r\n            output += `1. You must be the issuer of \"${assetCode}\"\\n`;\r\n            output += `2. Your account must have AUTH_REQUIRED or AUTH_REVOCABLE flags set\\n`;\r\n            output += `3. The trustor must have established a trustline to your asset\\n`;\r\n            output += `4. You must have XLM for transaction fees\\n\\n`;\r\n\r\n            output += `--- How to Execute ---\\n\\n`;\r\n\r\n            output += `Method 1: Using This Interface\\n`;\r\n            output += `1. Load your issuer wallet\\n`;\r\n            output += `2. Fill in the form above\\n`;\r\n            output += `3. Click \"Execute Allow Trust\"\\n\\n`;\r\n\r\n            output += `Method 2: Using Stellar Laboratory\\n`;\r\n            output += `1. Go to https:\/\/laboratory.stellar.org\\n`;\r\n            output += `2. Build transaction\\n`;\r\n            output += `3. Add \"Allow Trust\" operation:\\n`;\r\n            output += `   - Trustor: ${trustor}\\n`;\r\n            output += `   - Asset Code: ${assetCode}\\n`;\r\n            output += `   - Authorize: ${authorize}\\n`;\r\n            output += `4. Sign with your issuer secret key\\n`;\r\n            output += `5. Submit to ${NETWORKS[currentNetwork].name}\\n\\n`;\r\n\r\n            output += `Cost: ~${StellarSdk.BASE_FEE \/ 10000000} XLM\\n\\n`;\r\n\r\n            output += `--- What Happens ---\\n\\n`;\r\n            if (authorize) {\r\n                output += `\u2705 AUTHORIZE:\\n`;\r\n                output += `\u2022 The trustor will be able to hold and transact ${assetCode}\\n`;\r\n                output += `\u2022 Required if your account has AUTH_REQUIRED flag\\n`;\r\n            } else {\r\n                output += `\u274c REVOKE:\\n`;\r\n                output += `\u2022 The trustor's ${assetCode} balance will be frozen\\n`;\r\n                output += `\u2022 They cannot send or receive ${assetCode}\\n`;\r\n                output += `\u2022 Only works if your account has AUTH_REVOCABLE flag\\n`;\r\n                output += `\u2022 Cannot be undone if AUTH_REVOCABLE is later removed\\n`;\r\n            }\r\n\r\n            resultsDiv.textContent = output;\r\n        }\r\n\r\n        \/\/ =====================================================\r\n        \/\/ Change Trust Operation Handlers\r\n        \/\/ =====================================================\r\n\r\n        document.getElementById('changeTrustForm').addEventListener('submit', async (e) => {\r\n            e.preventDefault();\r\n\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            const assetCode = document.getElementById('trustAssetCode').value.trim().toUpperCase();\r\n            const issuer = document.getElementById('trustIssuer').value.trim();\r\n            const limitInput = document.getElementById('trustLimit').value.trim();\r\n\r\n            if (!assetCode || !issuer) {\r\n                alert('Please fill in asset code and issuer address');\r\n                return;\r\n            }\r\n\r\n            if (!isValidStellarAccount(issuer)) {\r\n                alert('Invalid issuer account address');\r\n                return;\r\n            }\r\n\r\n            \/\/ Convert empty limit to undefined (max), otherwise parse as number\r\n            const limit = limitInput ? limitInput : undefined;\r\n\r\n            const resultsDiv = document.getElementById('changeTrustResults');\r\n            resultsDiv.style.display = 'block';\r\n            resultsDiv.textContent = '\u23f3 Creating trustline...';\r\n\r\n            try {\r\n                const result = await executeChangeTrust(assetCode, issuer, limit);\r\n\r\n                resultsDiv.textContent = `\u2705 Trustline created successfully!\\n\\n` +\r\n                    `Asset: ${assetCode}\\n` +\r\n                    `Issuer: ${issuer}\\n` +\r\n                    `Limit: ${limit || 'Maximum (922337203685.4775807)'}\\n` +\r\n                    `Transaction Hash: ${result.hash}\\n\\n` +\r\n                    `View on Stellar Expert:\\n` +\r\n                    `${NETWORKS[currentNetwork].name === 'Testnet'\r\n                        ? `https:\/\/stellar.expert\/explorer\/testnet\/tx\/${result.hash}`\r\n                        : `https:\/\/stellar.expert\/explorer\/public\/tx\/${result.hash}`}`;\r\n            } catch (error) {\r\n                resultsDiv.textContent = `\u274c Error: ${error.message}`;\r\n            }\r\n        });\r\n\r\n        \/\/ Helper function to populate form from quick-add buttons\r\n        function setAsset(code, issuer) {\r\n            document.getElementById('trustAssetCode').value = code;\r\n            document.getElementById('trustIssuer').value = issuer;\r\n            document.getElementById('trustLimit').value = ''; \/\/ Set to max by default\r\n        }\r\n\r\n        async function executeChangeTrust(assetCode, issuer, limit) {\r\n            try {\r\n                const server = new StellarSdk.Horizon.Server(network.horizonUrl);\r\n                const account = await server.loadAccount(currentWallet.publicKey());\r\n\r\n                \/\/ Create asset object\r\n                const asset = new StellarSdk.Asset(assetCode, issuer);\r\n\r\n                \/\/ Build change trust operation\r\n                const changeTrustOp = limit\r\n                    ? StellarSdk.Operation.changeTrust({\r\n                        asset: asset,\r\n                        limit: limit.toString()\r\n                      })\r\n                    : StellarSdk.Operation.changeTrust({\r\n                        asset: asset\r\n                      });\r\n\r\n                \/\/ Build transaction\r\n                const transaction = new StellarSdk.TransactionBuilder(account, {\r\n                    fee: StellarSdk.BASE_FEE,\r\n                    networkPassphrase: network.passphrase\r\n                })\r\n                .addOperation(changeTrustOp)\r\n                .setTimeout(180)\r\n                .build();\r\n\r\n                \/\/ Sign transaction\r\n                transaction.sign(currentWallet);\r\n\r\n                \/\/ Submit to network\r\n                const result = await server.submitTransaction(transaction);\r\n\r\n                return {\r\n                    success: true,\r\n                    hash: result.hash\r\n                };\r\n\r\n            } catch (error) {\r\n                console.error('Full error:', error);\r\n\r\n                \/\/ Extract detailed error message from Horizon\r\n                let errorMsg = error.message;\r\n\r\n                if (error.response && error.response.data) {\r\n                    console.error('Horizon error details:', error.response.data);\r\n\r\n                    if (error.response.data.extras && error.response.data.extras.result_codes) {\r\n                        const codes = error.response.data.extras.result_codes;\r\n\r\n                        \/\/ Provide helpful error messages\r\n                        if (codes.operations && codes.operations.includes('op_malformed')) {\r\n                            errorMsg = 'Malformed operation: Check asset code (max 12 chars) and issuer address';\r\n                        } else if (codes.operations && codes.operations.includes('op_no_issuer')) {\r\n                            errorMsg = `No issuer found: The issuer account ${issuer} does not exist on the network`;\r\n                        } else if (codes.operations && codes.operations.includes('op_invalid_limit')) {\r\n                            errorMsg = 'Invalid limit: Limit must be greater than current balance or set to 0 to remove';\r\n                        } else if (codes.operations && codes.operations.includes('op_low_reserve')) {\r\n                            errorMsg = 'Low reserve: You need more XLM. Each trustline requires 0.5 XLM base reserve';\r\n                        } else if (codes.transaction === 'tx_insufficient_balance') {\r\n                            errorMsg = 'Insufficient balance: You need XLM for transaction fees';\r\n                        } else {\r\n                            errorMsg = `Transaction failed: ${codes.transaction || ''} - Operations: ${JSON.stringify(codes.operations || [])}`;\r\n                        }\r\n                    } else if (error.response.data.title) {\r\n                        errorMsg = error.response.data.title;\r\n                    }\r\n                }\r\n\r\n                throw new Error(errorMsg);\r\n            }\r\n        }\r\n\r\n        async function removeTrustline() {\r\n            if (!currentWallet) {\r\n                alert('Please create or import a wallet first');\r\n                return;\r\n            }\r\n\r\n            const assetCode = document.getElementById('trustAssetCode').value.trim().toUpperCase();\r\n            const issuer = document.getElementById('trustIssuer').value.trim();\r\n\r\n            if (!assetCode || !issuer) {\r\n                alert('Please fill in asset code and issuer address');\r\n                return;\r\n            }\r\n\r\n            if (!confirm(`\u26a0\ufe0f WARNING: This will remove your trustline to ${assetCode}.\\n\\nYou must have a ZERO balance of ${assetCode} before removing the trustline.\\n\\nContinue?`)) {\r\n                return;\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('changeTrustResults');\r\n            resultsDiv.style.display = 'block';\r\n            resultsDiv.textContent = '\u23f3 Removing trustline...';\r\n\r\n            try {\r\n                \/\/ Set limit to \"0\" to remove trustline\r\n                const result = await executeChangeTrust(assetCode, issuer, \"0\");\r\n\r\n                resultsDiv.textContent = `\u2705 Trustline removed successfully!\\n\\n` +\r\n                    `Asset: ${assetCode}\\n` +\r\n                    `Issuer: ${issuer}\\n` +\r\n                    `Transaction Hash: ${result.hash}\\n\\n` +\r\n                    `You have freed up 0.5 XLM base reserve!\\n\\n` +\r\n                    `View on Stellar Expert:\\n` +\r\n                    `${NETWORKS[currentNetwork].name === 'Testnet'\r\n                        ? `https:\/\/stellar.expert\/explorer\/testnet\/tx\/${result.hash}`\r\n                        : `https:\/\/stellar.expert\/explorer\/public\/tx\/${result.hash}`}`;\r\n            } catch (error) {\r\n                let errorMsg = error.message;\r\n\r\n                \/\/ Add specific guidance for common removal errors\r\n                if (errorMsg.includes('Invalid limit') || errorMsg.includes('balance')) {\r\n                    errorMsg += '\\n\\n\u2139\ufe0f Tip: You can only remove a trustline if your balance is exactly 0. Send all your tokens to another account first.';\r\n                }\r\n\r\n                resultsDiv.textContent = `\u274c Error: ${errorMsg}`;\r\n            }\r\n        }\r\n\r\n        function getInstructionsChangeTrust() {\r\n            const assetCode = document.getElementById('trustAssetCode').value.trim().toUpperCase();\r\n            const issuer = document.getElementById('trustIssuer').value.trim();\r\n            const limit = document.getElementById('trustLimit').value.trim();\r\n\r\n            if (!assetCode || !issuer) {\r\n                alert('Please fill in asset code and issuer address');\r\n                return;\r\n            }\r\n\r\n            if (!isValidStellarAccount(issuer)) {\r\n                alert('Invalid issuer account address');\r\n                return;\r\n            }\r\n\r\n            const resultsDiv = document.getElementById('changeTrustResults');\r\n            resultsDiv.style.display = 'block';\r\n\r\n            let output = `=== Change Trust (Create Trustline) Instructions ===\\n\\n`;\r\n            output += `Your Account: ${currentWallet ? currentWallet.publicKey() : '[Load wallet first]'}\\n`;\r\n            output += `Asset: ${assetCode}:${issuer.substring(0, 8)}...${issuer.substring(issuer.length - 4)}\\n`;\r\n            output += `Limit: ${limit || 'Maximum (922337203685.4775807)'}\\n\\n`;\r\n\r\n            output += `--- What is a Trustline? ---\\n\\n`;\r\n            output += `On Stellar, you must explicitly \"trust\" an asset before you can hold it.\\n`;\r\n            output += `This protects you from receiving unwanted or spam tokens.\\n\\n`;\r\n\r\n            output += `Creating a trustline means:\\n`;\r\n            output += `\u2022 You authorize your account to hold this asset\\n`;\r\n            output += `\u2022 You can receive payments in this asset\\n`;\r\n            output += `\u2022 You can send this asset to others\\n`;\r\n            output += `\u2022 It costs 0.5 XLM base reserve (refundable when you remove the trustline)\\n\\n`;\r\n\r\n            output += `--- Prerequisites ---\\n\\n`;\r\n            output += `1. You must have at least 1.5 XLM in your account:\\n`;\r\n            output += `   - 1 XLM minimum account balance\\n`;\r\n            output += `   - 0.5 XLM base reserve for the trustline\\n`;\r\n            output += `   - Small amount for transaction fees\\n`;\r\n            output += `2. The issuer account (${issuer.substring(0, 8)}...) must exist on the network\\n\\n`;\r\n\r\n            output += `--- Popular Assets ---\\n\\n`;\r\n            output += `\ud83d\udcb5 Circle USDC:\\n`;\r\n            output += `   Code: USDC\\n`;\r\n            output += `   Issuer: GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN\\n\\n`;\r\n            output += `\ud83d\udcb6 Circle EURC:\\n`;\r\n            output += `   Code: EURC\\n`;\r\n            output += `   Issuer: GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2\\n\\n`;\r\n            output += `\ud83c\udf0a Aquarius AQUA:\\n`;\r\n            output += `   Code: AQUA\\n`;\r\n            output += `   Issuer: GBNZILSTVQZ4R7IKQDGHYGY2QXL5QOFJYQMXPKWRRM5PAV7Y4M67AQUA\\n\\n`;\r\n            output += `\ud83e\ude99 Ultra Stellar yXLM:\\n`;\r\n            output += `   Code: yXLM\\n`;\r\n            output += `   Issuer: GARDNV3Q7YGT4AKSDF25LT32YSCCW4EV22Y2TV3I2PU2MMXJTEDL5T55\\n\\n`;\r\n\r\n            output += `--- How to Execute ---\\n\\n`;\r\n\r\n            output += `Method 1: Using This Interface (Recommended)\\n`;\r\n            output += `1. Load your wallet\\n`;\r\n            output += `2. Fill in the form above or click a quick-add button\\n`;\r\n            output += `3. Click \"Create Trustline\"\\n\\n`;\r\n\r\n            output += `Method 2: Using Stellar Laboratory\\n`;\r\n            output += `1. Go to https:\/\/laboratory.stellar.org\\n`;\r\n            output += `2. Build transaction\\n`;\r\n            output += `3. Add \"Change Trust\" operation:\\n`;\r\n            output += `   - Asset Code: ${assetCode}\\n`;\r\n            output += `   - Asset Issuer: ${issuer}\\n`;\r\n            output += `   - Trust Limit: ${limit || '[leave empty for max]'}\\n`;\r\n            output += `4. Sign with your secret key\\n`;\r\n            output += `5. Submit to ${NETWORKS[currentNetwork].name}\\n\\n`;\r\n\r\n            output += `Cost: ~${StellarSdk.BASE_FEE \/ 10000000} XLM transaction fee + 0.5 XLM base reserve\\n\\n`;\r\n\r\n            output += `--- To Remove a Trustline ---\\n\\n`;\r\n            output += `1. Send ALL your ${assetCode} tokens to another account (balance must be 0)\\n`;\r\n            output += `2. Click \"Remove Trustline\" button above\\n`;\r\n            output += `3. Your 0.5 XLM base reserve will be freed\\n\\n`;\r\n\r\n            output += `--- Trust Limits ---\\n\\n`;\r\n            output += `\u2022 Default: Maximum (922337203685.4775807)\\n`;\r\n            output += `\u2022 Custom: Set a limit if you want to restrict how much you can receive\\n`;\r\n            output += `\u2022 Example: Set limit to 1000 if you only want to hold up to 1000 ${assetCode}\\n\\n`;\r\n\r\n            output += `--- Security Tips ---\\n\\n`;\r\n            output += `\u26a0\ufe0f Only trust assets from verified issuers!\\n`;\r\n            output += `\u26a0\ufe0f Check the issuer address carefully - scammers create fake tokens\\n`;\r\n            output += `\u26a0\ufe0f Use Stellar Expert to verify asset authenticity:\\n`;\r\n            output += `   https:\/\/stellar.expert\/explorer\/public\/asset\/${assetCode}-${issuer}\\n\\n`;\r\n\r\n            output += `--- After Creating Trustline ---\\n\\n`;\r\n            output += `Once the trustline is created:\\n`;\r\n            output += `\u2022 You can receive ${assetCode} from anyone\\n`;\r\n            output += `\u2022 You can buy ${assetCode} on DEXs (like stellarx.com)\\n`;\r\n            output += `\u2022 You can see your ${assetCode} balance in your wallet\\n`;\r\n\r\n            resultsDiv.textContent = output;\r\n        }\r\n\r\n        \/\/ Initialize\r\n        updateNetworkStatus();\r\n        updateStatusMessage('Application loaded - Create or import wallet to begin');\r\n\r\n        \/\/ Pre-fill example account\r\n        document.getElementById('queryAccount').value = 'GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';\r\n\r\n        \/\/ Close modal when clicking outside\r\n        window.addEventListener('click', (event) => {\r\n            const modal = document.getElementById('importModal');\r\n            if (event.target === modal) {\r\n                modal.style.display = 'none';\r\n            }\r\n        });\r\n    <\/script>\r\n<\/body>\r\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Or send XLM to existing ones! You can fund newly created accounts with xlm you purchase from an exchange like Coinbase. I purchase and send it out usually right away because I would rather &#8220;hold&#8221; my own and you can too! We all know the banks are going to have to change their models or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-137","page","type-page","status-publish","hentry"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/pages\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stellardns.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=137"}],"version-history":[{"count":9,"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/pages\/137\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/stellardns.io\/index.php?rest_route=\/wp\/v2\/pages\/137\/revisions\/248"}],"wp:attachment":[{"href":"https:\/\/stellardns.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}