cosmos-crypto-lib

cosmos crypto lib

Usage no npm install needed!

<script type="module">
  import cosmosCryptoLib from 'https://cdn.skypack.dev/cosmos-crypto-lib';
</script>

README

cosmos-crypto-lib

npm version

Cosmos Crypto Library.

Quick Start

Install

yarn add cosmos-crypto-lib

Usage

1. import cosmos-crypto-lib

    const cosmosCrypto = require('cosmos-crypto-lib');

    const Crypto = cosmosCrypto.getCrypto();
    const crypto = new Crypto();

2. create a cosmos wallet

    const cosmosWallet = crypto.create(cosmosCrypto.config.language.en);
    assert.exists(cosmosWallet.address);

3. import a cosmos wallet by the private key

    const cosmosWallet = crypto.import("YOUR_PRIVATE_KEY");

4. import a cosmos wallet by mnemonic code

    const cosmosWallet = crypto.recover("YOUR_MNEMONIC_CODE", cosmosCrypto.config.language.en)

Because of network traffic, some operations like transfer, delegate, undelegate... may cause failures.

You have to retry for some more times.

Best way to solve this problem is to run your own node.

5. transfer

    const host = "https://stargate.cosmos.network";
    crypto.transfer(privateKey, "cosmoshub-2", host, "YOUR_FROM_ADDRESS", toAddress, "TRANSFER_AMOUNT");

6. delegate

    const host = "https://stargate.cosmos.network";
    crypto.delegate(privateKey, "cosmoshub-2", host, "YOUR_FROM_ADDRESS", "YOUR_VALIDATION_ADDR", "DELEGATE_UATOM_AMOUNT");

7. undelegate

    const host = "https://stargate.cosmos.network";
    crypto.undelegate(privateKey, "cosmoshub-2", host, "YOUR_FROM_ADDRESS", "YOUR_VALIDATION_ADDR", "DELEGATE_UATOM_AMOUNT");

ATOM to the moon!