Skip to content
martiliones edited this page Jun 12, 2023 · 1 revision

User

user.api

  • Type

    interface User {
      api: Api;
    }

user.id

The user's ADAMANT address

  • Type

    interface User {
      id: string;
    }

user.publicKey

The user's Public Key

  • Type

    interface User {
      publicKey: string;
    }

user.balance()

Gets the user's account balance

  • Type

    interface User {
      balance(): Promise<GetAccountBalanceResponseDto>;
    }
    
    interface GetAccountBalanceResponseDto {
      balance: string;
      nodeTimestamp: number;
      success: boolean;
      unconfirmedBalance: string;
    }

user.chatMessages()

Returns list of the chat messages between the bot and the user

  • Type

    interface User {
      chatMessages(): Promise<GetChatMessagesResponseDto>;
    }
    
    interface GetChatMessagesResponseDto {
      messages: (ChatMessageTransaction | TokenTransferTransaction)[];
      nodeTimestamp: number;
      participants: ChatParticipant[];
      success: boolean;
    }
    
    type TokenTransferTransaction = {
      asset: TokenTransferAsset;
      type: number;
    } & BaseTransaction;
    
    type ChatMessageTransaction = {
      asset: ChatMessageAsset;
      type: number;
    } & BaseTransaction;
    
    interface ChatParticipant {
      address: string;
      publicKey: string;
    }
    
    interface BaseTransaction {
      amount: number;
      asset: object;
      blockId: string;
      block_timestamp: number;
      confirmations: number;
      fee: number;
      height: number;
      id: string;
      recipientId: string;
      recipientPublicKey: string;
      senderId: string;
      senderPublicKey: string;
      signature: string;
      signatures: string[];
      timestamp: number;
      type: number;
    }
    
    type TokenTransferAsset = object;
    
    interface ChatMessageAsset {
      chat: { message?: string; own_message?: string; type?: number };
    }

user.info()

Returns the user's account information using

  • Type

    interface User {
      info(): Promise<GetAccountInfoResponseDto>;
    }
    
    interface GetAccountInfoResponseDto {
      account: AccountDto;
      nodeTimestamp: number;
      success: boolean;
    }
    
    interface AccountDto {
      address: string;
      balance: string;
      multisignatures: string[];
      publicKey: string;
      secondPublicKey: string;
      secondSignature: number;
      u_multisignatures: string[];
      unconfirmedBalance: string;
      unconfirmedSignature: number;
    }

user.reply()

Sends a message to the user

  • Type

    interface User {
      reply(
        message: string,
        messageType?: MessageType,
        amount?: number,
        isADM?: boolean
      ): Promise<TransferTokenResponseDto>;
    }
    
    interface TransferTokenResponseDto {
      nodeTimestamp: number;
      success: boolean;
      transactionId: string;
    }
  • References

    MessageType

user.send()

Sends the given amount of tokens to the user

  • Type

    interface User {
      send(amount: number, isADM?: boolean): Promise<TransferTokenResponseDto>;
    }
    
    interface TransferTokenResponseDto {
      nodeTimestamp: number;
      success: boolean;
      transactionId: string;
    }
Clone this wiki locally