Small collection of JavaScript functions for Metro. Allows for local signing of transactions, token creation/validation and encryption/decryption of arbitrary messages.
npm install mtrjs
npm test
var mtrjs = require('mtrjs');
// Create an account
var acc = mtrjs.secretPhraseToAccountId('secret');
console.log(acc);
Create the bundle with browserify:
browserify index.js -s mtrjs > build/mtrjs.js
Use in HTML file:
<script src="mtrjs.js"></script>
<script>
var acc = mtrjs.secretPhraseToAccountId('secret');
console.log(acc);
</script>
Returns public key of a given passphrase
Returns account ID of a given public key. Set the second parameter to true to get numeric account ID instead of RS format
Returns account ID of a given passphrase. Set the second parameter to true to get numeric account ID instead of RS format.
Signs a hex string of unsigned transaction bytes (e.g. as received from NRS API) with the provided passphrase and returns it.
Generates a Metro cryptographic token
Parses a Metro cryptographic token. Returns an object with the keys isValid
,
timestamp
, publicKey
and accountRS
.
Returns an object with the keys nonce
and message
Returns the deciphered text as string
Converts address in numeric format to Reed-Solomon format, or vice versa. Returns an object with the keys account
and accountRS