View Categories

Terminal State (User, Wallet & Global Objects)

2 min read

Understanding the internal data available to developers in the terminal runtime.

The Cointacted Social Terminal exposes a clean global object that developers can safely read to build advanced functionality:

CointactedSocialTerminalTerminal

This object contains:

  • user state
  • wallet state
  • settings
  • metadata
  • registry
  • runtime flags
  • helper references

This article documents every available property that developers can rely on.


πŸ”Ή 1. Global Root Object #

All terminal logic lives inside:

CointactedSocialTerminalTerminal

It is created by the core script and is available globally on the frontend.

You must not overwrite this object.
But you can safely read and extend parts of it.


πŸ”Ή 2. registry (Your Commands Live Here) #

This is where all executable commands are stored:

CointactedSocialTerminalTerminal.registry

Example:

registry.wallet
registry.help
registry.random
registry.mycustomcmd

You can:

  • add commands
  • override commands
  • extend commands

This is the main API for creating commands.


πŸ”Ή 3. commands_meta (Metadata for Help System) #

Contains:

  • groups
  • descriptions
  • aliases
  • public/private flags
  • hidden flags

Example:

CointactedSocialTerminalTerminal.commands_meta.wallet

You can:

  • add metadata for custom commands
  • override metadata for core commands
  • create new groups
  • hide commands

πŸ”Ή 4. user (Frontend User Object) #

Exposed from backend and available in JS.

Structure:

CointactedSocialTerminalTerminal.user = {
    id: NUMBER or null,
    is_logged_in: true/false,
    is_admin: true/false,
    roles: ["role1", "role2"],
    display_name: "John Doe",
};

This allows commands to adapt based on:

  • login state
  • role
  • admin privileges

Examples:

if (!CointactedSocialTerminalTerminal.user.is_logged_in) { ... }

if (CointactedSocialTerminalTerminal.user.is_admin) { ... }

πŸ”Ή 5. wallet (Read-Only, Safe Wallet Awareness) #

This object exists only if wallet detection is enabled and MetaMask exposes data.

Example structure:

CointactedSocialTerminalTerminal.wallet = {
    installed: true/false,
    connected: true/false,
    address: "0x...",
    chainId: "0x1",
    chainName: "Ethereum",
};

Important:

  • core never requests connection
  • core never sends transactions
  • this is purely awareness, not interaction

Wallet data is read-only unless your add-on adds real Web3 logic.

Example use:

if (CointactedSocialTerminalTerminal.wallet?.connected) {
    append_line("Wallet connected!", "wallet");
}

πŸ”Ή 6. settings (Backend-exposed Terminal Settings) #

Contains admin settings such as:

  • scroll mode
  • login URL
  • register URL
  • guest mode setting
  • wallet meta saving

Example:

CointactedSocialTerminalTerminal.settings = {
    scroll_mode: "inner" or "grow",
    login_url: "...",
    register_url: "...",
    guest_commands_enabled: true/false,
};

Developers can use these settings to adapt command behavior.


πŸ”Ή 7. state (Runtime Internal State) #

Used internally for:

  • cursor position
  • command history
  • last command
  • output DOM reference

Example structure:

CointactedSocialTerminalTerminal.state = {
    history: [],
    historyIndex: 0,
    lastCommand: "",
};

You can read this, but should not mutate it unless you know what you’re doing.


πŸ”Ή 8. Internal Helpers #

Some helper functions exist but are not part of the public API. Developers may observe them but should not overwrite them.

Examples (names may vary):

CointactedSocialTerminalTerminal.run()      // executes commands
CointactedSocialTerminalTerminal.scroll()   // forces scroll behavior
CointactedSocialTerminalTerminal.updateCursor()

Safe:

  • call run("cmd")
  • read values

Not safe:

  • replacing core helpers
  • modifying internal flow

πŸ”Ή 9. DOM References #

The terminal stores useful DOM references in:

CointactedSocialTerminalTerminal.dom

Typically includes:

{
    input: HTMLElement,
    output: HTMLElement,
    form: HTMLElement,
}

This allows add-ons to:

  • animate the terminal
  • inject DOM nodes
  • adjust styles

Example:

CointactedSocialTerminalTerminal.dom.output.style.border = "1px solid #3b82f6";

πŸ”Ή 10. Guest / Visitor Mode State #

Guest mode is determined by:

CointactedSocialTerminalTerminal.settings.guest_commands_enabled

Developers can check:

if (!CointactedSocialTerminalTerminal.user.is_logged_in &&
    !CointactedSocialTerminalTerminal.settings.guest_commands_enabled
) {
    append_line("Guests cannot use this command.", "error");
}

Core handles this automatically, but add-ons may need to check it too.


πŸ”Ή 11. Version Data (Optional but useful) #

Stored in:

CointactedSocialTerminalTerminal.version

Example:

"1.0.0"

Use it for compatibility checks.


πŸ”Ή 12. Putting It All Together β€” Example #

CointactedSocialTerminalTerminal.registry.status = function() {
    const user = CointactedSocialTerminalTerminal.user;
    const wallet = CointactedSocialTerminalTerminal.wallet;
    const settings = CointactedSocialTerminalTerminal.settings;

    append_line("--- Status ---", "system");

    append_line("User: " + (user.is_logged_in ? user.display_name : "Guest"), "system");
    append_line("Admin: " + (user.is_admin ? "Yes" : "No"), "system");

    if (wallet?.installed) {
        append_line("Wallet installed: yes", "wallet");
    }

    if (wallet?.connected) {
        append_line("Address: " + wallet.address, "wallet");
        append_line("Chain: " + wallet.chainName, "wallet");
    }

    append_line("Scroll mode: " + settings.scroll_mode, "system");
};

🎯 Summary #

The terminal exposes the following safe, stable objects:

βœ” registry β€” command functions #

βœ” commands_meta β€” descriptions, groups, aliases, visibility #

βœ” user β€” logged-in state, roles, admin flag, name #

βœ” wallet β€” read-only wallet awareness #

βœ” settings β€” admin-configured options #

βœ” state β€” internal runtime values #

βœ” dom β€” terminal DOM nodes #

βœ” version β€” plugin version #

These objects give developers full power to build advanced add-ons without touching core code.

Leave a Reply

Your email address will not be published. Required fields are marked *