How to use bs58

Comprehensive bs58 code examples:

How to use bs58.decode:

242
243
244
245
246
247
248
249
250
251
252
253


/*
For POW coins - used to format wallet address for use in generation transaction's output
 */
exports.addressToScript = function (addr) {
  var decoded = bs58.decode(addr);


  if (decoded.length != 25) {
    console.error("invalid address length for " + addr);
    throw new Error();

How to use bs58.encode:

249
250
251
252
253
254
255
256
257
258
it('should return JataContract as plain object', () => {
  const result = dataContract.toJSON();

  expect(result).to.deep.equal({
    protocolVersion: dataContract.getProtocolVersion(),
    $id: bs58.encode(contractId),
    $schema: DataContractDefaults.SCHEMA,
    version: 1,
    ownerId: bs58.encode(ownerId),
    documents,