Skip to content

Delegates

martiliones edited this page Jun 12, 2023 · 1 revision

Adamant: Delegates

adamantApi.getDelegate()

Get delegate info by username or publicKey

  • Type

    interface AdamantApi {
      getDelegate(
        options: UsernameOrPublicKeyObject
      ): Promise<GetDelegateResponseDto>;
    }
    
    interface GetDelegateResponseDto {
      delegate: DelegateDto;
      nodeTimestamp: number;
      success: boolean;
    }
    
    interface DelegateDto {
      address: string;
      approval: number;
      missedblocks: number;
      producedlocks?: number;
      productivity: number;
      publicKey: string;
      rank: number;
      rate: number;
      username: string;
      vote: string;
      votesWeight: string;
    }
  • References

    UsernameOrPublicKeyObject

adamantApi.getDelegateStats()

Get forging activity of a delegate

  • Type

    interface AdamantApi {
      getDelegateStats(
        generatorPublicKey: string
      ): Promise<GetDelegateStatsResponseDto>;
    }
    
    interface GetDelegateStatsResponseDto {
      fees: string;
      forged: string;
      nodeTimestamp: number;
      rewards: string;
      success: boolean;
    }

adamantApi.getDelegates()

Retrieves list of registered ADAMANT delegates

  • Type

    interface AdamantApi {
      getDelegates(options: GetDelegatesOptions): Promise<GetDelegatesResponseDto>;
    }
    
    interface GetDelegatesOptions {
      limit?: number;
      offset?: number;
    }
    
    interface GetDelegatesResponseDto {
      delegates: DelegateDto[];
      nodeTimestamp: number;
      success: boolean;
      totalCount: number;
    }
    
    interface DelegateDto {
      address: string;
      approval: number;
      missedblocks: number;
      producedlocks?: number;
      productivity: number;
      publicKey: string;
      rank: number;
      rate: number;
      username: string;
      vote: string;
      votesWeight: string;
    }

adamantApi.getDelegatesCount()

Get total count of delegates

  • Type

    interface AdamantApi {
      getDelegatesCount(): Promise<GetDelegatesCountResponseDto>;
    }
    
    interface GetDelegatesCountResponseDto {
      count: number;
      nodeTimestamp: number;
      success: boolean;
    }

adamantApi.getNextForgers()

returns list of next forgers

  • Type

    interface AdamantApi {
      getNextForgers(limit?: number): Promise<GetNextForgersResponseDto>;
    }
    
    interface GetNextForgersResponseDto {
      currentBlock: number;
      currentBlockSlot: number;
      currentSlot: number;
      delegates: string[];
      nodeTimestamp: number;
      success: boolean;
    }

adamantApi.getVoteData()

get current votes of specific ADAMANT account

  • Type

    interface AdamantApi {
      getVoteData(address: string): Promise<GetAccountVotesResponseDto>;
    }
    
    interface GetAccountVotesResponseDto {
      delegates: DelegateDto[];
      nodeTimestamp: number;
      success: boolean;
    }
    
    interface DelegateDto {
      address: string;
      approval: number;
      missedblocks: number;
      producedlocks?: number;
      productivity: number;
      publicKey: string;
      rank: number;
      rate: number;
      username: string;
      vote: string;
      votesWeight: string;
    }

adamantApi.getVoters()

gets list of delegate's voters

  • Type

    interface AdamantApi {
      getVoters(publicKey: string): Promise<GetVotersResponseDto>;
    }
    
    interface GetVotersResponseDto {
      accounts: VoterDto[];
      nodeTimestamp: number;
      success: boolean;
    }
    
    interface VoterDto {
      address: string;
      balance: string;
      publicKey: string;
      username: string;
    }

adamantApi.registerDelegate()

registers new delegate within given username

  • Type

    interface AdamantApi {
      registerDelegate(username: string): Promise<RegisterDelegateResponseDto>;
    }
    
    interface RegisterDelegateResponseDto {
      nodeTimestamp: number;
      success: boolean;
      transaction: RegisterDelegateTransactionDto;
    }
    
    type RegisterDelegateTransactionDto = {
      asset: RegisterDelegateAsset;
      fee?: number;
      type: number;
    } & QueuedTransaction;
    
    interface QueuedTransaction {
      amount: number;
      fee: number;
      id: string;
      receivedAt: string;
      recipientId: string;
      relays: number;
      senderId: string;
      senderPublicKey: string;
      signature: string;
      timestamp?: number;
      type: number;
    }
    
    interface RegisterDelegateAsset {
      delegate: { address: string; publicKey: string; username: string };
    }

adamantApi.searchDelegates()

Search delegates by username

  • Type

    interface AdamantApi {
      searchDelegates(q: string): Promise<SearchDelegateResponseDto>;
    }
    
    interface SearchDelegateResponseDto {
      delegates: SearchDelegateDto[];
      nodeTimestamp: number;
      success: boolean;
    }
    
    type SearchDelegateDto = {
      register_timestamp: number;
      voters_cnt: number;
    } & DelegateDto;
    
    interface DelegateDto {
      address: string;
      approval: number;
      missedblocks: number;
      producedlocks?: number;
      productivity: number;
      publicKey: string;
      rank: number;
      rate: number;
      username: string;
      vote: string;
      votesWeight: string;
    }

adamantApi.voteForDelegate()

votes for specific delegates

  • Type

    interface AdamantApi {
      voteForDelegate(votes: string[]): Promise<RegisterVotesResponseDto>;
    }
    
    interface RegisterVotesResponseDto {
      nodeTimestamp: number;
      success: boolean;
      transaction: RegisterVotesTransactionDto;
    }
    
    type RegisterVotesTransactionDto = {
      asset: VoteForDelegateAsset;
      nodeTimestamp: number;
      success: boolean;
      type: number;
    } & QueuedTransaction;
    
    interface QueuedTransaction {
      amount: number;
      fee: number;
      id: string;
      receivedAt: string;
      recipientId: string;
      relays: number;
      senderId: string;
      senderPublicKey: string;
      signature: string;
      timestamp?: number;
      type: number;
    }
    
    interface VoteForDelegateAsset {
      votes?: string[];
    }
  • Example

    voteForDelegate([
      '+b3d0c0b99f64d0960324089eb678e90d8bcbb3dd8c73ee748e026f8b9a5b5468',
      '-9ef1f6212ae871716cfa2d04e3dc5339e8fe75f89818be21ee1d75004983e2a8'
    ])