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

Adamant: Chat

adamantApi.getChatMessages()

Get messages between two accounts

  • Type

    interface AdamantApi {
      getChatMessages(
        address1: string,
        address2: string,
        options?: TransactionQuery<ChatroomsOptions>
      ): Promise<GetChatMessagesResponseDto>;
    }
    
    interface ChatroomsOptions {
      blockId?: number;
      fromHeight?: number;
      inId?: string;
      limit?: number;
      maxAmount?: number;
      minAmount?: number;
      offset?: number;
      orderBy?: string;
      recipientId?: string;
      senderId?: string;
      toHeight?: number;
      type?: number;
      withoutDirectTransfers?: boolean;
    }
    
    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 };
    }
  • References

    TransactionQuery

adamantApi.getChats()

Get list of Chats

  • Type

    interface AdamantApi {
      getChats(
        address: string,
        options?: TransactionQuery<ChatroomsOptions>
      ): Promise<GetChatRoomsResponseDto>;
    }
    
    interface ChatroomsOptions {
      blockId?: number;
      fromHeight?: number;
      inId?: string;
      limit?: number;
      maxAmount?: number;
      minAmount?: number;
      offset?: number;
      orderBy?: string;
      recipientId?: string;
      senderId?: string;
      toHeight?: number;
      type?: number;
      withoutDirectTransfers?: boolean;
    }
    
    interface GetChatRoomsResponseDto {
      chats: {
        lastTransaction?: ChatMessageTransaction | TokenTransferTransaction;
        participants?: ChatParticipant[];
      }[];
      nodeTimestamp: number;
      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 };
    }
  • References

    TransactionQuery

adamantApi.sendMessage()

Encrypts a message, creates Message transaction, signs it, and broadcasts to ADAMANT network. Supports Basic, Rich and Signal Message Types.

  • Type

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

    MessageType

adamantApi.sendTokens()

Send tokens to an account

  • Type

    interface AdamantApi {
      sendTokens(
        addressOrPublicKey: string,
        amount: number,
        isAmountInADM?: boolean
      ): Promise<TransferTokenResponseDto>;
    }
    
    interface TransferTokenResponseDto {
      nodeTimestamp: number;
      success: boolean;
      transactionId: string;
    }
Clone this wiki locally