Ethererum Helper

Address Helper

create new file addressHelper.jsx

import { Box, Button, Flex, IconButton, Text } from "@chakra-ui/react";
import React from "react";
import { FaCopy } from "react-icons/fa";
import { Link } from "react-router-dom";

import colors from "../Configs/colors";

function addressHelper(address, to) {
  const wallet = `${String(address).slice(0, 4)}...${String(address).slice(
    -4
  )}`;
    

  return (
    <Flex flexDirection="row" alignItems="center">
      <Box>
      <Link to={`/${to}/${address}`}>
      <Text>{wallet}</Text>
      </Link>
      </Box>
      <Box ml={3}>
      <IconButton
          size="sm"
          icon={<FaCopy />}
          color={colors.light}
          onClick={() => navigator.clipboard.writeText(address)}
                />
      </Box>
    </Flex>
    );
}

export default addressHelper;

if you want call the to call the helpers, use function in your project

Helper For Ethereum Decimal

create file decimalHelper.jsx in folder Utils

import React from "react";

function ethDecimalHelper(amount) {
  const data = amount / 1000000000000000000;
  if (data < 1) return data.toFixed(3);
  if (data > 1 && data < 10) return data.toFixed(2);
  if (data > 10) return data.toFixed(0);
}

export default ethDecimalHelper;

Last updated

Was this helpful?