AI Network
  • What is AI Network
  • AIN Blockchain
    • Architecture
      • Design Principles
      • Event-driven Architectures
      • Blockchain Database
        • States
          • State Types
          • Operations
          • Predefined Structures
        • Rules and Owners
          • Rule Configs
          • Owner Configs
        • Functions
          • Built-in Functions
      • Instant Execution, and Eventual Consistency
      • Network ID and Chain ID
      • Transactions
        • Structure
        • Nonce
        • Read Concern
        • Propagation
      • Block Structure
      • Account and Keys
      • Consensus
      • Scalability
      • Apps
    • Developer Guide
      • Quick Start
      • AI Network Products
        • AI Network Worker
        • AI Network Insight
        • Testnet Server Node
        • Ainize Trigger
          • Project user
          • Project deployer
          • Why do we have to use Ainize Trigger?
      • Token Bridge
      • Trouble Shooting
    • Developer Reference
      • Blockchain API
        • JSON RPC API
        • Node Client API
      • Blockchain SDK
        • ain-js
        • ain-py
      • Validators
    • Staking
  • AIN DAO
    • What is AIN DAO
      • Runo (Run Your Node)
      • GPU Sponsorship Program
    • Onboarding & Participation
    • Governance
    • Tokenomics
      • AI Network Tokenomics
      • AINFT Tokenomics
  • AI Agents
    • AINFT
    • AINFT Factory
    • AINFT Projects
      • 🍳MiniEggs
      • 🦈Baby Shark
      • 🛸Soul Fiction
      • 🎻NFT Classics Society
    • Developer Reference
      • Ainft-Js
      • AINFT tutorial
        • Create AINFT object and Mint
        • Transfer AINFT
        • Set metadata of AINFT
        • Search and Retrieve AINFT
  • AIN Wallet
    • What is AIN Wallet?
    • AIN Wallet API
  • PROPOSAL DOCUMENTS
    • AIN Improvement Memos (AIMs)
    • AIN Improvement Proposals (AIPs)
Powered by GitBook
On this page
  • What does AIN Wallet API do?
  • APIs

Was this helpful?

  1. AIN Wallet

AIN Wallet API

This document describes how to access AIN Wallet in a JavaScript based web app. Before following this article, make sure you have installed the AIN Wallet.

What does AIN Wallet API do?

AIN Wallet injects a JavaScript API into websites using the window.ainetwork object. This API allows websites to request users' AI Network accounts, and assists users in signing messages or sending transactions.

APIs

window.ainetwork.getAddress()

window.ainetwork.getAddress(): Promise<string>

Returns the address of the currently active account.

window.ainetwork.getAccount()

interface Account {
  name: string
  address: string
}

window.ainetwork.getAccount(): Promise<Account>

Returns the address of the currently active account.

window.ainetwork.getNetwork()

interface Network {
  chainId: number
  name: string
}

window.ainetwork.getAccount(): Promise<Network>

Returns the address of the currently active account.

window.ainetwork.getBalance()

window.ainetwork.getBalance(): Promise<number>

Returns the AIN token balance of the currently active account.

window.ainetwork.signMessage()

window.ainetwork.signMessage(message: string): Promise<string>

Returns the signature for message signed with the private key of the currently active account.

window.ainetwork.sendTransaction()

interface SetOperation {
  type: "SET_VALUE" | "INC_VALUE" | "DEC_VALUE" | "SET_RULE" | "SET_OWNER" | "SET_FUNCTION";
  ref: string;
  value: any | undefined | null;
  is_global?: boolean;
}

interface SetMultiOperation {
  type: "SET";
  op_list: SetOperation[];
}

interface TransactionInput {
  parent_tx_hash?: string;
  operation: SetOperation | SetMultiOperation;
  nonce?: number;
  address?: string;
  timestamp?: number;
  gas_price?: number;
  billing?: string;
}

window.ainetwork.sendTransaction(txInput: TransactionInput): Promise<string>

Sends transaction to the AI Network, and returns the transaction hash.

PreviousWhat is AIN Wallet?NextAIN Improvement Memos (AIMs)

Last updated 12 months ago

Was this helpful?