-
Notifications
You must be signed in to change notification settings - Fork 77
Description
As per shown in the example here
https://github.com/woodser/monero-ts/blob/master/docs/developer_guide/getting_started_p1.md
I have created a typescript project
Create a file in the src folder name offlineWallet.ts
compiled it using npx tsc
when i tried to run the file
using node dist/offlineWallet.js
got this error
`node dist/offlineWallet.js
/home/asif/AHOM/NativeMultiSig/MoneroBatcher/node_modules/monero-ts/dist/src/main/ts/common/MoneroWebWorker.js:1
"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");var _assert = _interopRequireDefault(require("assert"));
^
ReferenceError: require is not defined
at /home/asif/AHOM/NativeMultiSig/MoneroBatcher/node_modules/monero-ts/dist/src/main/ts/common/MoneroWebWorker.js:1:43
at Script.runInThisContext (node:vm:136:12)
at Object.runInThisContext (node:vm:316:38)
at importScripts (/home/asif/AHOM/NativeMultiSig/MoneroBatcher/node_modules/web-worker/dist/node/index.cjs:121:32)
at workerThread (/home/asif/AHOM/NativeMultiSig/MoneroBatcher/node_modules/web-worker/dist/node/index.cjs:138:64)
at Object. (/home/asif/AHOM/NativeMultiSig/MoneroBatcher/node_modules/web-worker/dist/node/index.cjs:55:114)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Object..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function._load (node:internal/modules/cjs/loader:1024:12)`
It the program keeps running until i quit it
my tsconfig.json
{ "include": ["src"], "compilerOptions": { "target": "es2016", "module": "commonjs", "rootDir": "./src", "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true } }
packag.json
{ "name": "monerobatcher", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "description": "", "dependencies": { "monero-ts": "^0.11.3", "typescript": "^5.7.3" } }
offlineWallet.ts
import moneroTs from "monero-ts";
main();
async function main() {
// create a random keys-only (offline) stagenet wallet
let walletKeys = await moneroTs.createWalletKeys({ networkType: moneroTs.MoneroNetworkType.STAGENET, language: "English" });
// print wallet attributes
console.log("Seed phrase: " + await walletKeys.getSeed());
console.log("Address: " + await walletKeys.getAddress(0, 0)); // get address of account 0, subaddress 0
console.log("Spend key: " + await walletKeys.getPrivateSpendKey());
console.log("View key: " + await walletKeys.getPrivateViewKey());
}