Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
ergonaddrjs
Advanced tools
JavaScript implementation for CashAddr address format for Ergon.
Compliant with the original CashAddr specification which improves upon BIP 173.
Note: This is a JavaScript implementation of the CashAddr format specification. If you are looking for a general purpose Bitcoin Cash address translation library, check out the easy-to-use and well-tested BchAddr.js.
$ npm install ergonaddrjs
You may also download the distribution file manually and place it within your third-party scripts directory: dist/ergonaddrjs-1.0.0.min.js.
Convert a bitcoincash:
prefixed address to an ergon:
prefixed address
const ergonaddr = require("ergonaddrjs");
const bitcoincashAddress =
"bitcoincash:qpadrekpz6gjd8w0zfedmtqyld0r2j4qmuj6vnmhp6";
const { prefix, type, hash } = ergonaddr.decode(bitcoincashAddress);
console.log(prefix); // 'bitcoincash'
console.log(type); // 'P2PKH'
console.log(hash); // Uint8Array [ 118, 160, ..., 115 ]
console.log(cashaddr.encode("ergon", type, hash));
// 'ergon:qpadrekpz6gjd8w0zfedmtqyld0r2j4qmunpeyresh'
import cashaddr from "ergonaddrjs";
function convertBitcoincashToErgon(bitcoincashAddress) {
/* NOTE
This function assumes input parameter 'bitcoincashAddress' is a valid bitcoincash: address
cashaddr.decode() will throw an error if 'bitcoincashAddress' lacks a prefix
*/
const { prefix, type, hash } = cashaddr.decode(bitcoincashAddress);
const ergonAddress = cashaddr.encode("ergon", type, hash);
return ergonAddress;
}
<html>
<head>
<script src="https://unpkg.com/ergonaddrjs@1.0.0/dist/cashaddrjs-1.0.0.min.js"></script>
</head>
<body>
<script>
function convertBitcoincashToErgon(bitcoincashAddress) {
/* NOTE
This function assumes input parameter 'bitcoincashAddress' is a valid bitcoincash: address
cashaddr.decode() will throw an error if 'bitcoincashAddress' lacks a prefix
*/
const { prefix, type, hash } = ergonaddr.decode(bitcoincashAddress);
const ergonAddress = ergonaddr.encode("ergon", type, hash);
return ergonAddress;
}
const ergonAddress = convertBitcoincashToErgon(
"bitcoincash:qpadrekpz6gjd8w0zfedmtqyld0r2j4qmuj6vnmhp6"
);
console.log(ergonAddress);
// ergon:qpadrekpz6gjd8w0zfedmtqyld0r2j4qmunpeyresh
</script>
</body>
</html>
You may include a script tag in your HTML and the ergonaddr
module will be defined globally on subsequent scripts.
<html>
<head>
...
<script src="https://unpkg.com/ergonaddrjs@1.0.0/dist/cashaddrjs-1.0.0.min.js"></script>
</head>
...
</html>
FAQs
Ergon address format support for Node.js and web browsers.
The npm package ergonaddrjs receives a total of 44 weekly downloads. As such, ergonaddrjs popularity was classified as not popular.
We found that ergonaddrjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.