Closed georgewslee closed 4 months ago
const bs58 = require('bs58'); const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS' const bytes = bs58.decode(address) // See uint8array-tools package for helpful hex encoding/decoding/compare tools console.log(Buffer.from(bytes).toString('hex')) // => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187
when i run it, I get the following error: const bytes = bs58.decode(address) ---------------------^ TypeError: bs58.decode is not a function
What am I doing wrong? Anything to do with esm? I need to use it in a commonJs script.
When using an ESM module in commonjs, the default import is called default
default
const bs58 = require('bs58').default;
const bs58 = require('bs58'); const address = '16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS' const bytes = bs58.decode(address) // See uint8array-tools package for helpful hex encoding/decoding/compare tools console.log(Buffer.from(bytes).toString('hex')) // => 003c176e659bea0f29a3e9bf7880c112b1b31b4dc826268187
when i run it, I get the following error: const bytes = bs58.decode(address) ---------------------^ TypeError: bs58.decode is not a function
What am I doing wrong? Anything to do with esm? I need to use it in a commonJs script.