Advertisement
lscofield

decode.js

Aug 11th, 2022
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { toBn } = require("evm-bn")
  2. const ethers = require('ethers')
  3.  
  4. const FromWei = (amount, decimals) => {
  5.     return amount / (10 ** decimals)
  6. }
  7.  
  8. const ToWei = (amount, decimals) => {
  9.     return ethers.BigNumber
  10.         .from(toBn(amount.toString(), decimals)._hex).toString()
  11. }
  12.  
  13. const Random = (list) => {
  14.     return list[Math.floor(Math.random() * list.length)]
  15. }
  16.  
  17. module.exports = {
  18.     FromWei,
  19.     ToWei,
  20.     Random
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement