Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BitcloutClient

A BitClout node API client

Example:

import { Client } from '@cloutjs/api'

const client = new Client('figure various run...', 'https://my-bitclout-node.io')
beta

Hierarchy

  • BaseClient
    • BitcloutClient

Index

Constructors

constructor

  • new BitcloutClient(identityArg?: null | string | Identity | ReadonlyIdentity | WebAccount | SeedAccount, nodeURL?: string, otherCfg?: Partial<ClientConfig>): BitcloutClient
  • Initialize a BitClout node client

    Parameters

    • Optional identityArg: null | string | Identity | ReadonlyIdentity | WebAccount | SeedAccount

      This will be the identity used by the client in requests and for signing transactions (optional).

      It must be an instance of WebAccount (for sending requests on behalf of client-side users), SeedAccount (for server-side bots exclusively - NEVER ASK A USER FOR THEIR SEED PHRASE), ReadonlyIdentity (which is just a read-only public key and can't sign transactions), or any custom class that extends Identity.

      You can also supply a 12-word seed phrase mnemonic if you want to automatically generate a SeedAccount. Or, pass a bitclout public key to automatically generate a ReadonlyIdentity.

      Finally, if you pass null or undefined, the client will be created without an identity, but won't be able to access many endpoints.

    • nodeURL: string = 'https://bitclout.com'

      URL of the BitClout node (without the final slash). This is bitclout.com by default, though it is recommended to host your own node.

    • Optional otherCfg: Partial<ClientConfig>

      Other configuration for the client

    Returns BitcloutClient

Properties

admin

admin: { getGlobalParams: any }

Node admin endpoints

Type declaration

  • getGlobalParams: function
    • getGlobalParams(): Promise<any>
    • TODO

      Returns Promise<any>

Optional identity

identity: Identity | ReadonlyIdentity

Client's identity instance, used for generating and signing transactions, etc.

Methods

callApi

  • callApi<T>(endpoint: string, data?: Record<string, any> | FormData, method?: "GET" | "POST"): Promise<T>
  • Make a call to the node API

    Type parameters

    • T: Record<string, any>

    Parameters

    • endpoint: string

      Endpoint to call (nodeUrl/api/v0/ENDPOINT)

    • Optional data: Record<string, any> | FormData

      JSON body (or query params for GET request)

    • method: "GET" | "POST" = 'POST'

      GET or POST; defualts to POST

    Returns Promise<T>

    the API response

checkTransaction

  • Check if a transaction is currently in the mempool

    Parameters

    • TxnHashHex: string

      This is the transaction hash hex, not the full transaction hex.

    Returns Promise<GetTransactionResponse>

follow

  • Follow a user.

    identityrequired

    Parameters

    • publicKey: string

      The public key of the user to follow

    Returns Promise<FollowTxnResponse>

    The follow transaction result

getAppState

  • Get state of BitClout, such as cost of profile creation and diamond tiers

    Returns Promise<GetAppStateResponse>

getExchangeRate

healthCheck

  • healthCheck(): Promise<{ ok: true }>
  • Checks the sync status of the node. Throws an error if check is not succesful.

    Returns Promise<{ ok: true }>

    ok: true if the node is running and synced, otherwise throws an error.

like

  • Like a post

    identityrequired

    Parameters

    • postHash: string

      The hash hex of the post to like

    Returns Promise<LikeTxnResponse>

    The like transaction result

sendBitclout

  • Send bitclout to another wallet

    identityrequired

    Parameters

    • recipient: string

      The BitClout public key OR username of the recipient

    • amountNanos: number

      How many nanos of BitClout to send

    Returns Promise<SendBitcloutTxnResponse>

    The transaction result

sendDiamonds

  • Give diamonds to a post

    identityrequired

    Parameters

    • recipient: string

      The recipient of the diamonds (the creator of the post)

    • postHash: string

      The post hash hex

    • diamondLevel: number

      How many diamonds? Use BitcloutClient.getAppState to get the diamond tiers.

    Returns Promise<SendDiamondsTxnResponse>

    The diamond transaction result

signAndSubmitTransaction

  • signAndSubmitTransaction<T>(txn: string): Promise<T>
  • Signs and submits a transaction

    Type parameters

    • T: Record<string, any>

    Parameters

    • txn: string

      The unsigned transaction hex

    Returns Promise<T>

    The API response

submitPost

  • Submit a post

    identityrequired

    Parameters

    • body: string

    Returns Promise<PostTxnResponse>

    The transaction result

submitTransaction

  • submitTransaction<T>(txn: string): Promise<T>
  • Submits a signed transaction using the /submit-transaction endpoint

    Type parameters

    • T: Record<string, any>

    Parameters

    • txn: string

      The signed transaction hex

    Returns Promise<T>

    The API response

transferCreatorCoin

  • Transfers some creator coin to another wallet

    Parameters

    • creator: string

      The Bitclout public key of the coin's creator

    • recipient: string

      The Bitclout public key or username of the coin recipient

    • coinNanos: number

      The amount of nanos of coin to transfer

    Returns Promise<TransferCreatorCoinTxnResponse>

    The transfer transaction result

unfollow

  • Unfollow a user.

    identityrequired

    Parameters

    • publicKey: string

      The public key of the user to unfollow

    Returns Promise<FollowTxnResponse>

    The follow transaction result

unlike

  • Unlike a post

    identityrequired

    Parameters

    • postHash: string

      The hash hex of the post to unlike

    Returns Promise<LikeTxnResponse>

    The like transaction result

updateProfile

  • Update profile

    identityrequired

    Parameters

    Returns Promise<UpdateProfileTxnResponse>

    Information about the update transaction

uploadImage

  • Uploads an image to the BitClout node from current identity

    identityrequired

    Parameters

    • file: File

    Returns Promise<UploadImageResponse>

Generated using TypeDoc