1.Gweiで求めた値をGweiもしくはETHで表示する
・小数点以下の表示の設定
・symbol
・pattern
2.require
・currency.js
3.code
const currency = require('currency.js');
・・・
let t = parseFloat(total) / 1000000000;
const CURRENCY_ETH = {
"formatWithSymbol" : true,
"symbol" : "ETH",
"separator" : ",",
"decimal" : ".",
"precision" : 9,
"pattern" : "# !"
}
const CURRENCY_GWei = {
"formatWithSymbol" : true,
"symbol" : "Gwai",
"separator" : ",",
"decimal" : ".",
"precision" : 0,
"pattern" : "# !"
}
let msg;
if( total >1000) {
msg ={ total: currency(t.toString(),CURRENCY_Gwai).format(true) }
} else {
msg ={ total: currency(total.toString(),CURRENCY_ETH).format(true) }
}
console.log(msg.total)