-
Install the module
npm install @mydogeofficial/dogecoin-js
-
Import and use
import { DogecoinJS } from '@mydogeofficial/dogecoin-js' async function run() { const dogecoin_js = await DogecoinJS.init() const [privKey, pubKey] = dogecoin_js.generatePrivPubKeypair() console.log(`generated: ${privKey} ${pubKey}`) }
-
Init submodules
libdogecoin
andemsdk
git submodule init git submodule update
-
Init
emsdk
-
Linux
cd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh
-
Mac M1
brew install --ignore-dependencies emscripten
-
-
Configure and compile
libdogecoin
usingemscripten
cd libdogecoin ./autogen.sh emconfigure ./configure CC=emcc AR=emar --host wasm32 --disable-net --disable-tools --disable-dependency-tracking emmake make
-
Export
libdogecoin
javascript functionscd libdogecoin/.libs emcc -sSTRICT=1 -sEXPORTED_FUNCTIONS=_dogecoin_ecc_start,_dogecoin_ecc_stop,_generatePrivPubKeypair,_generateHDMasterPubKeypair,_generateDerivedHDPubkey,_getDerivedHDAddressByPath,_getDerivedHDAddress,_verifyPrivPubKeypair,_verifyHDMasterPubKeypair,_verifyP2pkhAddress,_start_transaction,_add_utxo,_add_output,_finalize_transaction,_get_raw_transaction,_clear_transaction,_sign_raw_transaction,_sign_transaction,_store_raw_transaction,_free,_malloc -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stackAlloc,UTF8ToString,intArrayFromString,stringToUTF8,allocateUTF8,setValue,getValue -sMODULARIZE=1 -sENVIRONMENT='web,worker,node' -sEXPORT_NAME=loadWASM -sSINGLE_FILE=1 libdogecoin.a ../src/secp256k1/.libs/libsecp256k1.a -o ../../lib/libdogecoin.js
-
Test bindings
npm i npm test