0.0.2 • Published 1 year ago

realtime-crypto-price v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Licence npm version Downloads

realtime-crypto-price

Fetchs the price of crypto in USDT from Binance API.

Installation

npm i realtime-crypto-price

Live Demo

https://codesandbox.io/s/realtime-crypto-price-eij1g8

Example

import "./styles.css";
import { ChainSymbols, getCryptoPrice } from "realtime-crypto-price";
import { useEffect, useState } from "react";

export default function App() {
  const [nearPrice, setNearPrice] = useState("0");
  const getNearPrice = async () => {
    const res = await getCryptoPrice(ChainSymbols.NEAR);
    setNearPrice(res?.price || "0");
  };

  useEffect(() => {
    getNearPrice();
  }, []);

  return (
    <div className="App">
      <h1>realtime-crypto-price</h1>
      <p>Current NEAR Price: {nearPrice} $</p>
    </div>
  );
}

API

PropertyTypeDescription
walletstringWallet name.
rpcNearRPCTESTNET or MAINNET.