npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

decentr-js

v5.3.7

Published

decentr-js

Downloads

31

Readme

decentr-js

decentr-js

NPM version Downloads


✨ Features

  • Mnemonic generation (24 words combination)
  • Wallet generation based on mnemonic (address, private key, public key)
  • Querying to almost all decentr services
  • Creating and broadcasting transactions

🔧 Installation

npm install decentr-js

🎬 Getting started

#Table of contents

  1. Mnemonic
  2. Wallet
  3. Decentr API
    1. Status
    2. Auth
    3. Bank
    4. Blocks
    5. Community
    6. Distribution
    7. Mint
    8. Operations
    9. Staking
    10. Token
    11. Tx
  4. Cerberus API
    1. Configuration
    2. Image
    3. PDV
    4. Profile
    5. Rewards
  5. Theseus API
    1. DDV
    2. Posts
    3. Profile
  6. Vulcan API
    1. Referral
    2. Registration
    3. Loan
  7. License

Mnemonic

Generate mnemonic phrase (24 words)

import { generateMnemonic } from 'decentr-js';
const mnemonic = generateMnemonic();
/*
    fantasy scatter misery seminar resist file unique coral ordinary wash shoulder demise bubble calm sail protect divide write lend card sudden rally depart park
*/

Wallet

Create wallet with address and keys

import { createWalletFromMnemonic } from "decentr-js"

const seed = ...12 seed words here  
const wallet = createWalletFromMnemonic(seed);

/*
{
    address:    'decentr1j6e6j53vh95jcq9k9lnsrsvj3h8dkdgmm20zhu',
    validatorAddress: 'decentrvaloper1p4s4djk5dqstfswg6k8sljhkzku4a6ve9dmng5',
    privateKey: '8c313682470073d56d2d8f5b7fde53c072024a9fd9135501125035d53c8a1f60',
    publicKey: '03dae8cf229d1db63c8d854bd1c73e280147ebd3bb40df12381d16b0eb071a72b6'
}
*/

Using Decentr api

Decentr client

For less text, we define some basic variables here

import { DecentrClient } from 'decentr-js';

const NODE_URL = 'http://rest.testnet.decentr.xyz:26657'; // blockchain node

const privateKey = 'decentrPrivateKey'; // optional, if you do not need to use sign functionality

const decentrClient = await DecentrClient.create(NODE_URL, privateKey);

Status

  const status = await decentrClient.status();

Response of status method is a StatusResponse.

📜 Auth

Auth client has the following interface

  class AuthClient {
    getAccount(walletAddress: Wallet['address']): Promise<Account | null>;
  }

How to get instance of auth client

  const authClient = decentrClient.auth;

Methods

  1. Get account
  const walletAddress = 'decentr1234567890abcdefghijklmno';
  const account = await authClient.getAccount(walletAddress);

Response of getAccount method is an Account or null if account is not exist.

📜 Bank

Bank client has the following interface

  class BankClient {
    getBalance(walletAddress: Wallet['address']): Promise<Coin[]>;

    getDenomBalance(walletAddress: Wallet['address'], denom: string): Promise<Coin>;

    getSupply(): Promise<Coin[]>;
    
    getDenomSupply(denom: string): Promise<Coin>;
    
    public sendTokens(
      request: SendTokensRequest,
    ): TransactionSigner;
  }

How to get instance of bank client

  const bankClient = decentrClient.bank;

Methods

  1. Get balance
  const walletAddress = 'decentr1234567890abcdefghijklmno';
  const balance = await bankClient.getBalance(decentr1234567890abcdefghijklmno);

Response of getBalance method is a Coin array.

  1. Get denom balance
  const walletAddress = 'decentr1234567890abcdefghijklmno';
  const denom = 'udec';
  const denomBalance = await bankClient.getDenomBalance(decentr1234567890abcdefghijklmno, denom);

Notice: denom is an optional param, it is udec by default.

Response of getDenomBalance method is a Coin.

  1. Get supply
  const walletAddress = 'decentr1234567890abcdefghijklmno';
  const supply = await bankClient.getSupply(decentr1234567890abcdefghijklmno);

Response of getSupply method is a Coin array.

  1. Get denom supply
  const denom = 'udec';
  const denomSupply = await bankClient.getDenomSupply(denom);

Notice: denom is an optional param, it is udec by default.

Response of getDenomSupply method is a Coin.

  1. Send tokens
  const message = {
    fromAddress: 'decentrFromAddress',
    toAddress: 'decentrToAddress',
    amount: [
      {
        amount: '100000000',
        denom: 'udec',
      },
    ],
  };
  const transactionSigner = bankClient.sendTokens(message);

transactionSigner is an interface that allows simulate or broadcast transaction

  const gas = await transactionSigner.simulate(); // estimated gas that will be spent on broadcasting
  const transaction = await transactionSigner.signAndBroadcast('My gift to decentr user');

Response of signAndBroadcast method is a DeliverTxResponse.

📜 Blocks

Blocks client has the following interface

  class BlocksClient {
    getBlock(height?: BlockHeader['height']): Promise<Block>;
  }

How to get instance of bank client

  const blocksClient = decentrClient.blocks;

Methods

  1. Get block
  const height = 12345;
  const block = await blocksClient.getBlock(decentr1234567890abcdefghijklmno)

Notice: height is an optional param, method will return the latest block if height is not supplied.

Response of getBlock method is a Block.

📜 Community

Community client has the following interface

  class CommunityClient {
    getModeratorAddresses(): Promise<Wallet['address'][]>;

    getFollowees(follower: Wallet['address']): Promise<Wallet['address'][]>;

    createPost(
      request: MsgCreatePost['post'],
    ): TransactionSigner;

    deletePost(
      request: MsgDeletePost,
    ): TransactionSigner;

    setLike(
      request: MsgSetLike['like'],
    ): TransactionSigner;

    follow(
      request: MsgFollow,
    ): TransactionSigner;

    unfollow(
      request: MsgUnfollow,
    ): TransactionSigner;
  }

How to get instance of community client

  const communityClient = decentrClient.community;

Methods

  1. Get moderators
  const moderators = await communityClient.getModeratorAddresses();

Response of getModeratorAddresses method is a wallet addresses array;

  1. Get followees
  const walletAddress = 'decentr123456789abcdefghijklmno';
  const followees = await communityClient.getFollowees(walletAddress);

Response of getFollowees method is a wallet address array;

  1. Create post
  import { PostCategory } from 'decentr-js';
  const message = {
    owner: 'decentrAuthorAddress', // author's walletAddress
    uuid: '12345-abcde-67890-fghijk',
    title: 'Post title',
    previewImage: 'http://image.png',
    category: PostCategory.CATEGORY_TRAVEL_AND_TOURISM,
    text: 'Post text',
  };
  const transactionSigner = communityClient.createPost(message);

Notice: more about transactionSigner you can read here

  1. Delete post
  const message = {
    postOwner: 'decentrAuthorAddress',
    postUuid: '12345-abcde-67890-fghijk',
    owner: 'decentrInitiatorAddress',
  };
  const transactionSigner = communityClient.deletePost(message);

Notice: more about transactionSigner you can read here

  1. Set like
  import { LikeWeight } from 'decentr-js'
  const message = {
    postOwner: 'decentrAuthorAddress',
    postUuid: '12345-abcde-67890-fghijk',
    owner: 'decentrInitiatorAddress',
    weight: LikeWeight.LIKE_WEIGHT_UP,
  };
  const transactionSigner = communityClient.deletePost(message);

Notice: more about transactionSigner you can read here

  1. Follow
  import { LikeWeight } from 'decentr-js'
  const message = {
    owner: 'decentrFollowerAddress',
    whom: 'decentrWhomToFollowAddress',
  };
  const transactionSigner = communityClient.deletePost(message);

Notice: more about transactionSigner you can read here

  1. Unfollow
  import { LikeWeight } from 'decentr-js'
  const message = {
    owner: 'decentrFollowerAddress',
    whom: 'decentrWhomToUnfollowAddress',
  };
  const transactionSigner = communityClient.deletePost(message);

Notice: more about transactionSigner you can read here

📜 Distribution

Distribution client has the following interface

  class DistributionClient {
    getCommunityPool(): Promise<Coin[]>;

    getDistributionParameters(): Promise<Params>;

    getDelegatorRewards(delegatorAddress: Wallet['address']): Promise<QueryDelegationTotalRewardsResponse>;

    getDelegatorRewardsFromValidator(
      delegatorAddress: Wallet['address'],
      validatorAddress: Validator['operatorAddress'],
    ): Promise<Coin[]>;

    getWithdrawAddress(delegatorAddress: Wallet['address']): Promise<Wallet['address']>;

    getValidatorCommission(validatorAddress: Validator['operatorAddress']): Promise<Coin[]>;

    getValidatorOutstandingRewards(validatorAddress: Validator['operatorAddress']): Promise<Coin[]>;

    setWithdrawAddress(
      request: SetWithdrawAddressRequest,
    ): TransactionSigner;
    
    withdrawDelegatorRewards(
      request: WithdrawDelegatorRewardRequest,
    ): TransactionSigner;
    
    withdrawValidatorRewards(
      request: WithdrawValidatorCommissionRequest,
    ): TransactionSigner;
  }

How to get instance of distribution client

  const distributionClient = decentrClient.distribution;

Methods

  1. Get community pool
  const communityPool = await distributionClient.getCommunityPool();

Response of getCommunityPool method is a Coin array.

  1. Get parameters
  const parameters = await distributionClient.getDistributionParameters(walletAddress);

Response of getDistributionParameters method is a Params;

  1. Get delegator rewards
  const delegatorAddress = 'decentrDelegatorAddress';
  const delegatorRewards = await distributionClient.getDelegatorRewards(delegatorAddress);

Response of getDelegatorRewards method is a QueryDelegationTotalRewardsResponse

  1. Get delegator rewards from validator
  const delegatorAddress = 'decentrDelegatorAddress';
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const delegatorRewards = await distributionClient.getDelegatorRewardsFromValidator(delegatorAddress, validatorAddress);

Response of getDelegatorRewardsFromValidator method is a Coin array.

  1. Get withdraw address
  const walletAddress = 'decentrWalletAddress';
  const withdrawAddress = await distributionClient.getWithdrawAddress(walletAddress);

Response of getWithdrawAddress method is a wallet address where staking rewards will be transferred;

  1. Get validator commission
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const commission = await distributionClient.getValidatorCommission(validatorAddress);

Response of getValidatorCommission method is a Coin array.

  1. Get validator outstanding rewards
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const outstandingRewards = await distributionClient.getValidatorOutstandingRewards(validatorAddress);

Response of getValidatorOutstandingRewards method is a Coin array.

  1. Set withdraw address
  const message = {
    delegatorAddress: 'decentrDelegatorAddress',
    withdrawAddress: 'decentrWithdrawAddrews',
  };
  const transactionSigner = distributionClient.setWithdrawAddress(message);

Notice: more about transactionSigner you can read here

  1. Withdraw delegator rewards
  const messages = [
    {
      delegatorAddress: 'decentrDelegatorAddress',
      validatorAddress: 'decentrWithdrawAddrews1',
    },
    {
      delegatorAddress: 'decentrDelegatorAddress',
      validatorAddress: 'decentrWithdrawAddrews2',
    },
  ];
  const transactionSigner = distributionClient.withdrawDelegatorRewards(messages);

Notice: more about transactionSigner you can read here

  1. Withdraw validator rewards
  const message = {
     validatorAddress: 'decentrvaloperValidatorAddress',
  };
  const transactionSigner = distributionClient.withdrawValidatorRewards(message);

Notice: more about transactionSigner you can read here

📜 Mint

Mint client has the following interface

  class MintClient {
    getInflation(): Promise<string>;
  }

How to get instance of mint client

  const mintClient = decentrClient.mint;

Methods

  1. Get inflation
  const inflation = await mintClient.getInflation();

Response of getInflation method is a string like 0.135.

📜 Operations

Operations client has the following interface

  class OperationsClient {
    getMinGasPrice(): Promise<Coin>;

    resetAccount(
      request: ResetAccountRequest,
    ): TransactionSigner;
  }

How to get instance of operations client

  const operationsClient = decentrClient.operations;

Methods

  1. Get min gas price
  const minGasPrice = await operationsClient.getMinGasPrice();

Response of getMinGasPrice method is a Coin

  1. Reset account
  const message = {
    owner: 'decentrInitiatorAddress',
    address: 'decentrResetAddress',
  };
  const transactionSigner = operationsClient.resetAccount(message);

Notice: more about transactionSigner you can read here

📜 Staking

Staking client has the following interface

  class StakingClient {
    getPool(): Promise<Pool>;

    getValidators(status: BondStatusString): Promise<Validator[]>;

    getValidator(address: Validator['operatorAddress']): Promise<Validator>;

    getDelegations(delegatorAddress: Wallet['address']): Promise<DelegationResponse[]>;

    getDelegation(
      delegatorAddress: Wallet['address'],
      validatorAddress: Validator['operatorAddress'],
    ): Promise<Coin | null>;

    getValidatorDelegations(validatorAddress: Validator['operatorAddress']): Promise<DelegationResponse[]>;

    getUnbondingDelegations(delegatorAddress: Wallet['address']): Promise<UnbondingDelegation[]>;

    getUnbondingDelegation(
      delegatorAddress: Wallet['address'],
      validatorAddress: Validator['operatorAddress'],
    ): Promise<UnbondingDelegation | undefined>;
    
    getValidatorUnbondingDelegations(
      validatorAddress: Validator['operatorAddress'],
    ): Promise<UnbondingDelegation[]>;
    
    getRedelegations(
      delegatorAddress: Wallet['address'],
      sourceValidatorAddress: Validator['operatorAddress'],
      destinationValidatorAddress: Validator['operatorAddress'],
    ): Promise<RedelegationResponse[]>;
    
    getDelegatorValidators(
      delegatorAddress: Wallet['address'],
    ): Promise<Validator[]>;
    
    getStakingParameters(): Promise<Params>;
    
    delegateTokens(
      request: DelegateTokensRequest,
    ): TransactionSigner;
    
    undelegateTokens(
      request: UndelegateTokensRequest,
    ): TransactionSigner;
    
    redelegateTokens(
      request: RedelegateTokensRequest,
    ): TransactionSigner;
  }

How to get instance of staking client

  const stakingClient = decentrClient.staking;

Methods

  1. Get pool
  const pool = await stakingClient.getPool();

Response of pool method is a Pool

  1. Get validators
  const validators = await stakingClient.getValidators('BOND_STATUS_BONDED');

Response of getValidators method is a Validator array.

  1. Get validator
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const validator = await stakingClient.getValidator(validatorAddress);

Response of getDelegatorRewards method is a Validator

  1. Get delegations
  const delegatorAddress = 'decentrDelegatorAddress';
  const delegations = await stakingClient.getDelegations(delegatorAddress);

Response of getDelegatorRewardsFromValidator method is a DelegationResponse array.

  1. Get delegation
  const delegatorAddress = 'decentrDelegatorAddress';
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const delegation = await stakingClient.getDelegation(delegatorAddress, validatorAddress);

Response of getDelegation method is a Coin array.

  1. Get validator delegations
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const validatorDelegations = await stakingClient.getValidatorDelegations(validatorAddress);

Response of getValidatorDelegations method is a DelegationResponse array.

  1. Get unbonding delegations
  const delegatorAddress = 'decentrDelegatorAddress';
  const unbondingDelegations = await stakingClient.getUnbondingDelegations(delegatorAddress);

Response of getUnbondingDelegations method is a UnbondingDelegation array.

  1. Get unbonding delegation
  const delegatorAddress = 'decentrDelegatorAddress';
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const unbondingDelegation = await stakingClient
    .getUnbondingDelegation(delegatorAddress, validatorAddress);

Response of getUnbondingDelegation method is a UnbondingDelegation

  1. Get validator unbonding delegations
  const validatorAddress = 'decentrvaloperValidatorAddress';
  const unboindingDelegations = await stakingClient
    .getValidatorUnbondingDelegations(validatorAddress, validatorAddress);

Response of getValidatorUnbondingDelegations method is a UnbondingDelegation array.

  1. Get redelegations
  const delegatorAddress = 'decentrDelegatorAddress';
  const sourceValidatorAddress = 'decentrvaloperSourceValidatorAddress';
  const destinationValidatorAddress = 'decentrvaloperDestinationValidatorAddress';
  const redelegations = await stakingClient.getRedelegations(
    delegatorAddress,
    sourceValidatorAddress,
    destinationValidatorAddress,
  );

Response of getRedelegations method is a RedelegationResponse array.

  1. Get delegator validators
  const delegatorAddress = 'decentrDelegatorAddress';
  const validators = await stakingClient.getDelegatorValidators(delegatorAddress);

Response of getDelegatorValidators method is a Validator array.

  1. Get staking parameters
  const parameters = await stakingClient.getStakingParameters();

Response of getStakingParameters method is a Params

  1. Delegate tokens
  const message = {
    delegatorAddress: 'decentrDelegatorAddress',
    validatorAddress: 'decentrvaloperValidatorAddress',
    amount: [
      {
        amount: '100000000',
        denom: 'udec',
      },
    ],
  };
  const transactionSigner = stakingClient.delegateTokens(message);

Notice: more about transactionSigner you can read here

  1. Undelegate tokens
  const message = {
    delegatorAddress: 'decentrDelegatorAddress',
    validatorAddress: 'decentrvaloperValidatorAddress',
    amount: {
      amount: '100000000',
      denom: 'udec',
    },
  };
  const transactionSigner = stakingClient.undelegateTokens(message);

Notice: more about transactionSigner you can read here

  1. Redelegate tokens
  const message = {
    delegatorAddress: 'decentrDelegatorAddress',
    validatorSrcAddress: 'decentrvaloperSourceValidatorAddress',
    validatorDstAddress: 'decentrvaloperDestinationValidatorAddress',
    amount: {
      amount: '100000000',
      denom: 'udec',
    },
  };
  const transactionSigner = stakingClient.redelegateTokens(message);

Notice: more about transactionSigner you can read here

📜 Token

Token client has the following interface

  class TokenClient {
    getBalance(walletAddress: Wallet['address']): Promise<string>;
  }

How to get instance of token client

  const tokenClient = decentrClient.token;

Methods

  1. Get PDV balance
  const walletAddress = 'decentrWalletAddress';
  const balance = await tokenClient.getBalance(walletAddress);

Response of getBalance method is a string like 1.001234.

📜 Tx

Tx client has the following interface

  class TxClient {
    search(query: SearchTxQuery,filter: SearchTxFilter = {}): Promise<DecodedIndexedTx[]>
    
    getByHash(hash: IndexedTx['hash']): Promise<DecodedIndexedTx>;
  }

How to get instance of tx client

  const txClient = decentrClient.tx;

Methods

  1. Search txs
  const queryByHeight = { height: 123456 };
  const txsByHeight = await txClient.search(queryByHeight);

  const queryBySentFromOrTo = { sentFromOrTo: 'decentrWalletAddress' };
  const txsBySentFromOrTo = await txClient.search(queryByHeight);

  const queryByTags = { tags: [
      {
        key: 'message.module',
        value: 'staking',
      },
      {
        key: 'message.sender',
        value: 'decentrWalletAddress',
      },
    ],
  };
  const txsByTags = await txClient.search(queryByHeight);

Response of search method is an DecodedIndexedTx array.

  1. Get by hash
  const txHash = 'ABCDEF0123456GHIJKL7890';
  const tx = await txClient.getByHash(txHash);

Response of getByHash method is an DecodedIndexedTx

Using Cerberus api

Cerberus client

For less text, we define some basic variables here

import { CerberusClient } from 'decentr-js';

const CERBERUS_URL = 'https://cerberus.mainnet.decentr.xyz';

const cerberusClient = new CerberusClient(CERBERUS_URL);

📜 Configuration

Configuration client has the following interface

  class CerberusConfigurationClient {
    getPDVBlacklist(): Promise<PDVBlacklist>;

    getPDVRewards(): Promise<PDVRewards>;
  }

How to get instance of configuration client

  const configurationClient = cerberusClient.configuration;

Methods

  1. Get PDV blacklist
  const pDVBlacklist = await configurationClient.getPDVBlacklist();

Response of getPDVBlacklist method is a PDVBlacklist

  1. Get PDV rewards configuration
  const pDVRewards = await configurationClient.getPDVRewards();

Response of getPDVRewards method is a PDVRewards

📜 Image

Image client has the following interface

  class CerberusImageClient {
    save(image: File, privateKey: Wallet['privateKey']): Promise<SaveImageResponse>;
  }

How to get instance of image client

  const imageClient = cerberusClient.image;

Methods

  1. Save image
  const image = 'your image file of File interface';
  const privateKey = '1234567890abcdefghijklmno';
  const imageResponse = await imageClient.saveImage(image, privateKey);

Response of saveImage method is an SaveImageResponse

📜 PDV

PDV client has the following interface

  class CerberusPDVClient {
    getPDVList(
      walletAddress: Wallet['address'],
      paginationOptions?: PDVListPaginationOptions,
    ): Promise<PDVListItem[]>;
    
    getPDVMeta(pdvAddress: number, walletAddress: Wallet['address']): Promise<PDVMeta>;
    
    getPDVDetails(pdvAddress: number, wallet: Wallet): Promise<PDVDetails>;
    
    sendPDV(pdv: PDV[], privateKey: Wallet['privateKey']): Promise<PDVAddress>;
    
    validate(pdv: PDV[]): Promise<number[]>;
  }

How to get instance of PDV client

  const pDVClient = cerberusClient.pdv;

Methods

  1. Get PDV list
  const walletAddress = 'decentrPDVOwnerAddress';
  const pagination = {
    limit: 20,
    from: 12345678, // optional, timestamp of previous PDVListItem
  };
  const pdvList = operationsClient.getPDVList(walletAddress, pagination);

Response of getPDVList method is an id (timestamp) array like [1641748368, 1641744563, 164158725]

  1. Get PDV meta
  const walletAddress = 'decentrPDVOwnerAddress';
  const pDVAddress = 1641748368;
  const pDVMeta = await pDVClient.getPDVMeta(pDVAddress, walletAddress);

Response of getPDVMeta method is a PDVMeta

  1. Get PDV details
  const wallet = { 
    address: 'decentrPDVOwnerAddress',
    privateKey: '1234567890abcdefghijklmno',
    publicKey: 'abcdefghijklmno1234567890',
  };
  const pDVAddress = 1641748368;
  const pDVDetails = await pDVClient.getPDVDetails(pDVAddress, wallet);

Response of getPDVDetails method is a PDVDetails

  1. Send PDV
  const PDV = []; // array of your PDV's;
  const privateKey: '1234567890abcdefghijklmno';
  const pDVAddress = await pDVClient.sendPDV(pdv, privateKey);

Response of sendPDV method is an id (timestamp) of PDV.

  1. Validate PDV
  const PDV = []; // array of your PDV's;
  const invalidPDVIndexes = await pDVClient.validate(pdv);

Response of validate method is an indexes array of invalid PDV.

📜 Profile

Profile client has the following interface

  class CerberusProfileClient {
    setProfile(
      profile: ProfileUpdate,
      privateKey: Wallet['privateKey'],
    ): Promise<PDVAddress>;

    getProfile(
      walletAddress: Wallet['address'],
      privateKey: Wallet['privateKey'],
   ): Promise<Profile>;
    
    getProfiles(
      walletAddresses: Wallet['address'][],
      privateKey: Wallet['privateKey'],
    ): Promise<Record<Profile['address'], Profile>>;
  }

How to get instance of PDV client

  const profileClient = cerberusClient.profile;

Methods

  1. Set profile
  import { Gender } from 'decentr-js';
  const profile = {
    avatar: 'http://avatar.png',
    bio: 'bio',
    birthday: '1991-01-01',
    emails: ['[email protected]'],
    firstName: 'firstName',        // maxlength: 64
    gender: Gender.Male,
    lastName: 'lastName',          // maxlength: 64
  } 
  const privateKey = '1234567890abcdefghijklmno';
  const pDVAddress = await profileClient.setProfile(profile, privateKey);

Response of setProfile method is an id (timestamp) of PDV.

  1. Get profile
  const walletAddress = 'decentrAddress';
  const privateKey = '1234567890abcdefghijklmno';
  // privateKey is an optional param required to get private profile data (birthday, gender etc.)
  const profile = await profileClient.getProfile(walletAddress, privateKey);

Response of getProfile method is a Profile

  1. Get profiles
  const walletAddresses = ['decentrAddress1', 'decentrAddress2'];
  const privateKey = '1234567890abcdefghijklmno';
  // privateKey is an optional param required to get private profile data only for request initiator profile (birthday, gender etc.)
  const profiles = await profileClient.getProfiles(walletAddress, privateKey);

Response of getProfiles method is an object of type { decentrAddress1: profileObj1, decentrAddress2: profileObj2 }.

📜 Rewards

Rewards client has the following interface

  class CerberusRewardsClient {
    getDelta(walletAddress: Wallet['address']): Promise<TokenDelta>;
    
    getPool(): Promise<TokenPool>;
  }

How to get instance of rewards client

  const rewardsClient = cerberusClient.rewards;

Methods

  1. Get delta
  const walletAddress = 'decentrWalletAddress';
  const delta = await tokenClient.getDelta(walletAddress);

Response of getDelta method is an TokenDelta

  1. Get pool
  const pool = await tokenClient.getPool();

Response of getPool method is an TokenPool

Using Theseus api

Theseus client

For less text, we define some basic variables here

import { TheseusClient } from 'decentr-js';

const THESEUS_URL = 'https://theseus.mainnet.decentr.xyz';

const theseusClient = new TheseusClient(THESEUS_URL);

📜 DDV

DDV client has the following interface

  class TheseusDDVClient {
    getStats(): Promise<DDVStats>;
  }

How to get instance of ddv client

  const ddvClient = theseusClient.ddv;

Methods

  1. Get stats
  const stats = await ddvClient.getStats();

Response of getStats method is a DDVStats

📜 Posts

Posts client has the following interface

  class TheseusPostsClient {
    getPost(params: Pick<Post, 'owner' | 'uuid'>, requestedBy: Wallet['address']): Promise<PostResponse>;

    getPosts(filterOptions?: PostsListFilterOptions): Promise<PostsListResponse>;
  }

How to get instance of profile client

  const postsClient = theseusClient.posts;

Methods

  1. Get post
  const postParams = { 
    owner: 'decentrWalletAddress',
    uuid: 'post-uuid-1234',
  };
  const requestedBy = 'decentrSameOrAnotherWalletAddress';
  const stats = await postsClient.getPost(postParams, requestedBy);

Response of getPost method is a PostResponse

  1. Get posts
  const filter = {
    category: PostCategory.CATEGORY_WORLD_NEWS,
    requestedBy: 'decentrSameOrAnotherWalletAddress',
  }; // optional
  const balance = await postsClient.getPosts(filter);

Interface of filter object described here PostsListFilterOptions

Response of getPosts method is an PostsListResponse

📜 Profile

Profile client has the following interface

  class TheseusProfileClient {
    getProfileStats(walletAddress: Wallet['address']): Promise<ProfileStatistics>;

    getAdvDdvStats(): Promise<AdvDdvStatistics>;
  }

How to get instance of profile client

  const profileClient = theseusClient.profile;

Methods

  1. Get profile stats
  const walletAddress = 'decentrAddress';
  const stats = await profileClient.getProfileStats(walletAddress);

Response of getProfileStats method is a ProfileStatistics

  1. Get ADV/DDV stats
  const walletAddress = 'decentrWalletAddress';
  const balance = await profileClient.getAdvDdvStats();

Response of getAdvDdvStats method is an AdvDdvStatistics

Using Vulcan api

Vulcan client

For less text, we define some basic variables here

import { VulcanClient } from 'decentr-js';

const VULCAN_URL = 'https://vulcan.mainnet.decentr.xyz';

const vulcanClient = new VulcanClient(VULCAN_URL);

📜 Referral

Referral client has the following interface

  class VulcanReferralClient {
    getCode(walletAddress: Wallet['address']): Promise<string>;

    getConfig(): Promise<ReferralConfig>;
    
    getStats(walletAddress: Wallet['address']): Promise<ReferralTimeStats>;
    
    trackInstall(walletAddress: Wallet['address']): Promise<void>;
  }

How to get instance of referral client

  const referralClient = vulcanClient.referral;

Methods

  1. Get code
  const walletAddress = 'decentrAddress';
  const code = await referralClient.getCode(walletAddress);

Response of getCode method is a string code like abc123

  1. Get configuration
  const config = await referralClient.getConfig();

Response of getConfig method is an ReferralConfig

  1. Get statistics
  const walletAddress = 'decentrAddress';
  const stats = await referralClient.getStats();

Response of getStats method is an ReferralTimeStats

  1. Track install
  const walletAddress = 'decentrAddress';
  await referralClient.trackInstall(walletAddress);

📜 Registration

Registration client has the following interface

  class VulcanReferralClient {
    register(walletAddress: Wallet['address'], email: string): Promise<void>;

    confirm(email: string, code: string): Promise<void>;
    
    hesoyam(walletAddress: Wallet['address']): Promise<void>;
    
    getStats(): Promise<RegistrationStats>;
  }

How to get instance of registration client

  const registrationClient = vulcanClient.registration;

Methods

  1. Register user
  const walletAddress = 'decentrAddress';
  const email = '[email protected]';
  await registrationClient.register(walletAddress, email);
  1. Confirm registration
  const email = '[email protected]';
  const code = 'a1b2c3';
  await registrationClient.confirm(email, code);
  1. Hesoyam
  const walletAddress = 'decentrAddress';
  await registrationClient.hesoyam(walletAddress);
  1. Get stats
  await registrationClient.getStats();

Response of getStats method is an RegistrationStats

📜 Loan

Loan client has the following interface

  class VulcanLoanClient {
    requestLoan(loan: Loan): Promise<void>;
  }

How to get instance of loan client

  const loanClient = vulcanClient.loan;

Methods

  1. Request loan
  const loan = {
    firstName: "John",
    lastName: "Doe", *(Optional)*
    pdvRate: 1.12345678,
    walletAddress: "decentrAddress"
  }
  await loanClient.requestLoan(loan);

🥂 License

MIT as always