I created a 'create react app' with typescript and I now want to import and use eosjs-ecc

Can I just import it with yarn add eosjs-ecc and then do

import ecc from 'eosjs-ecc'

or do I need to clone the repo then build a browser version with yarn build_browser

(notice the browser section at the bottom of the readme eosjs-ecc)

then copy the built file eosjs-ecc.js into the project and then import that built file with...

import ecc from './scripts/eosjs-ecc.js'

it feels wrong to have to add the js file when all the other file are tsx files. I notice there is no type definitions either.


Yes, that's how you would go about it:

import ecc from 'eosjs-ecc'
// or
const ecc = require('eosjs-ecc')

// example
ecc.randomKey().then(privateKey => {
    console.log('Private Key:\t', privateKey) // wif
    console.log('Public Key:\t', ecc.privateToPublic(privateKey)) // EOSkey...

// Install with:
yarn add eosjs-ecc


An example of LiquidApps using eosjs-ecc in our version of b1's Elemental Battles (http://cardgame1112.dnsregistry1.com/)

const ecc = require('eosjs-ecc')


  • so no need to do the yarn build_browser ? – Bill Jul 27 '19 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.