@nekoproject/networks
TypeScript icon, indicating that this package has built-in type declarations

2.1.12 • Public • Published

@nekoproject/networks

A complete crypto wallet base support for cross-chain

Table of contents

Build

Re-build project from scratch

  • Clean project
      npm run clean
  • Build
      npm run build
  • Unit test
      npm run test:cover

Install

Install @nekoproject/networks with npm

  npm i @nekoproject/networks

Import

  import { Network, SPLNetwork } from '@nekoproject/networks'
  import type { Web3Provider, OrderRequest, SPLTransactionRequest, SPLTransactionResponse } from '@nekoproject/networks'

Documents

Use created instance

   import { SPLNetworkInstance } from '@nekoproject/networks'

Create new Network instance

  const config: Web3Provider = {
    rpcUrl: 'rpc URL',
    explorer: 'https://solscan.io',
  }
  let network: Network;
  network = new SPLNetwork(config)

Network methods

Setter

  • Set new RPC URL
      network.rcpUrl = 'new rpc URL'
  • Set new explorer URL
      network.explorerUrl = 'new explorer URL'

Getter

  • Get provider (Connection)
      const provider = network.provider

Get SOL balance

  /**
 * 
 * @param address : string
 * @returns : SOL balance (not lamport unit)
 */
  const balance = await network.getBalance(address)

Create transaction Order

  const order: OrderRequest = {
    from: 'address',
    to: 'address',
    amount: 'SOL value'
  }
  /**
 * Create order for transaction
 * @param order: OrderRequest
 * @returns : SPLTransactionRequest
 */
  const transsactionOrder = await network.createTransactionOrder(order)
  

Send transaction

   /**
 * Send transaction
 * @param transactionOrder: SPLTransactionRequest
 * @param wallet : Wallet
 * @returns : signature
 */
  const signature = await network.sendTransaction(transactionOrder, wallet)

Get transaction

  /**
 * Get detail of finalized transaction by signature
 * @param signature : signature of transaction
 * @returns : SPLTransactionResponse
 */
  const response = await network.getTransaction(signature)

Sign message

  /**
 * Sign message
 * @param message : string
 * @param wallet: Wallet
 * @returns : signature of signed message
 */
  const signature = network.signMessage(wallet, message)

Verify message

   /**
 * Verify message signed
 * @param wallet : Wallet
 * @param signature: signature of signed message
 * @params message: message signed
 * @returns : signature of signed message
 */
  const verify = network.verifyMessage(wallet, signature, message)

Notice

Ref

Package Sidebar

Install

npm i @nekoproject/networks

Weekly Downloads

2

Version

2.1.12

License

MIT

Unpacked Size

57.4 MB

Total Files

110

Last publish

Collaborators

  • nekoglobal
  • minhdc0902