0

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.

0

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

https://github.com/EOSIO/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')

https://github.com/liquidapps-io/zeus-sdk/blob/master/boxes/groups/sample/cardgame/frontends/main/src/services/ApiService.js#L3

  • so no need to do the yarn build_browser ? – Bill Jul 27 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.