0.1.0 • Published 3 years ago

solana-client-js v0.1.0

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

solana-client-js

Solana library for managing wallet and transfering tokens.

Install

  npm install solana-client-js

APIs

Initialize

  const { Solana } = require('solana-client-js');

  const SolanaClient = new Solana();

  // or 

  const SolanaClient = new Solana(
    'https://api.mainnet-beta.solana.com', // main net url
  );

  await solanaClient.setToken('SGT');

Store wallets

  // Add wallet(name, secretKeyArray)
  await solanaClient.addWallet('myWallet', [106,241,17,...,25,111,29,121,118]);

  // Add destination (name, publicKey)
  await solanaClient.addDestination('myReceiver', "8z4Wq1gz1u...kNZcDS77KLq");

Getting balance of wallets

  // Getting Token balance
  const balance = await solanaClient.getWalletBalance('myWallet');

    // Getting Solana balance
  const balance = await solanaClient.getWalletBalance('myWallet', false);

Transfer tokens

U should change token infoes to transfer other tokens. (Defalut SGT)

  /*
    ...
    store sender's wallet, payer's wallet and receiver's publicKey
    ...
  */

  const transfers = [
    {walletName: 'sender', destinationName: 'receiver', amount: 1},
    {walletName: 'sender', destinationName: 'receiver', amount: 2}
  ]

  const res = await solanaClient.transferTokens(transfers, 'payer');

  console.log(`signatures: ${res}}\ncheck: https://explorer.solana.com/tx/${res}`);

Contributors

GGULBAE

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago