0.2.0 • Published 2 years ago

@decentralchain/provider-seed v0.2.0

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

ProviderSeed

Overview

ProviderSeed implements a Signature Provider for Signer protocol library. ProviderSeed creates user account from SEED.

Getting Started

1. Library installation

To install Signer and ProviderSeed libraries use

npm i @decentralchain/signer @decentralchain/provider-seed @decentralchain/waves-transactions

2. Library initialization

Add library initialization to your app.

  • For Testnet:

    import { Signer } from '@decentralchain/signer';
    import { ProviderSeed } from '@decentralchain/provider-seed';
    import { libs } from '@decentralchain/waves-transactions';
    
    const seed = libs.crypto.randomSeed();
    const signer = new Signer({
      // Specify URL of the node on Testnet
      NODE_URL: 'https://testnet-node.decentralchain.io'
    });
    const provider = new ProviderSeed(seed);
    signer.setProvider(provider);
  • For Mainnet:

    import { Signer } from '@decentralchain/signer';
    import { ProviderSeed } from '@decentralchain/provider-seed';
    import { libs } from '@decentralchain/waves-transactions';
    
    const seed = libs.crypto.randomSeed();
    const signer = new Signer();
    const provider = new ProviderSeed(seed);
    signer.setProvider(provider);

3. Basic example

Now your application is ready to work with Waves Platform. Let's test it by implementing basic functionality. For example, we could try to authenticate user and transfer funds.

const user = await signer.login();
const [transfer] = await signer
  .transfer({
    amount: 1,
    recipient: 'alias:T:merry',
  })
  .sign();

For more information see Signer documentation.