1.1.0 • Published 6d ago
tokenization-util
Licence
UNLICENSED
Version
1.1.0
Deps
0
Size
14 kB
Vulns
1
Weekly
727
Tokenization Util
This is a simple reusable Node module for REFE-style real-estate tokenization projects. It has no external dependencies and can be used in this project or another Node/React project.
What It Includes
- Wallet helpers
- Mongo ObjectId validation
- Real-estate token calculation helpers
- Currency, number, and percent formatting
- API URL joining
- Basic REFE project metadata
Usage In This Project
From the repository root, install workspaces first:
npm installThen import it from another workspace:
const {
calculateTokenPrice,
formatCurrency,
shortenWalletAddress,
} = require("tokenization-util");
const tokenPrice = calculateTokenPrice(500000, 5000);
console.log(formatCurrency(tokenPrice));
console.log(shortenWalletAddress("0x742d35Cc6634C0532925a3b844Bc454e44381440"));Usage In Another Project
Install from a local folder:
npm install ../real-estate-web3/refe-platform-moduleOr create a tarball:
cd refe-platform-module
npm packThen install the generated .tgz file in another project:
npm install ./refe-platform-module-0.1.0.tgzAvailable Helpers
const {
projectInfo,
getProjectOverview,
isEthereumAddress,
normalizeWalletAddress,
shortenWalletAddress,
isMongoObjectId,
calculateTokenPrice,
calculateInvestmentValue,
calculateTokenOwnership,
calculateTokenAmount,
formatCurrency,
formatNumber,
formatPercent,
formatTokenSummary,
createApiUrl,
} = require("tokenization-util");Examples
calculateTokenPrice(500000, 5000);
// 100
calculateInvestmentValue(10, 100);
// 1000
calculateTokenOwnership(100, 5000);
// 2
calculateTokenAmount(1050, 100);
// 10
formatCurrency(1000);
// "$1,000.00"
formatPercent(2);
// "2.00%"
formatTokenSummary("Example Property", 5000);
// "Example Property: 5,000 property tokens"
createApiUrl("https://api.example.com/", "/api/property");
// "https://api.example.com/api/property"Local Test
From the repository root:
npm run test --workspace tokenization-utilOr from this folder:
npm test