rusty-kaspa icon indicating copy to clipboard operation
rusty-kaspa copied to clipboard

Execute node demo.js and report an error

Open Ligang9 opened this issue 1 year ago • 4 comments

Execute node demo.js and report an error

  1. cargo run --release --bin kaspad -- --rpclisten-json=127.0.0.1:17110
  2. cd wasm
  3. cd nodejs
  4. node demo.js --network=mainnet 5.7a7440ee783988a2e132bea6b22f991fb971c4eca2f3378e2a99aded7df353ae 027a7440ee783988a2e132bea6b22f991fb971c4eca2f3378e2a99aded7df353ae Full kaspa address: kaspa:qpa8gs8w0quc3ghpx2l2dv30ny0mjuwyaj30xduw92v6mmta7df6uayhcthxq { version: 'PubKey', prefix: 'kaspa', payload: 'qpa8gs8w0quc3ghpx2l2dv30ny0mjuwyaj30xduw92v6mmta7df6uayhcthxq' } Connecting to ws://127.0.0.1:17110 Connected to ws://127.0.0.1:17110 C:\Users\Administrator\Desktop\rusty-kaspa\wasm\nodejs\kaspa\kaspa_wasm.js:9347 const ret = new Error(getStringFromWasm0(arg0, arg1)); ^

Error: RPC Server (remote error) -> WebSocket disconnected at module.exports.__wbindgen_error_new (C:\Users\Administrator\Desktop\rusty-kaspa\wasm\nodejs\kaspa\kaspa_wasm.js:9347:17) at wasm://wasm/01c0c6fa:wasm-function[545]:0x1c7bda at wasm://wasm/01c0c6fa:wasm-function[1558]:0x308070 at wasm://wasm/01c0c6fa:wasm-function[5091]:0x4bc1c6 at __wbg_adapter_67 (C:\Users\Administrator\Desktop\rusty-kaspa\wasm\nodejs\kaspa\kaspa_wasm.js:272:10) at real (C:\Users\Administrator\Desktop\rusty-kaspa\wasm\nodejs\kaspa\kaspa_wasm.js:243:20)

Node.js v18.19.1

Ligang9 avatar Apr 23 '24 04:04 Ligang9

Please try WASM SDK development builds (or build from source) from PR https://github.com/kaspanet/rusty-kaspa/pull/459

also, please use --rpclisten-borsh= if running a local node as Borsh encoding is the default setting in examples.

aspect avatar Apr 23 '24 04:04 aspect

1.Change to cargo run --release --bin kaspad -- --rpclisten-borsh 2.Use kaspa-wasm32-sdk-latest\kaspa-wasm32-sdk\nodejs\kaspa.js 3.require('./kaspa/kaspa_wasm') is changed to require('./kaspa/kaspa') 7a7440ee783988a2e132bea6b22f991fb971c4eca2f3378e2a99aded7df353ae 027a7440ee783988a2e132bea6b22f991fb971c4eca2f3378e2a99aded7df353ae Full kaspa address: kaspa:qpa8gs8w0quc3ghpx2l2dv30ny0mjuwyaj30xduw92v6mmta7df6uayhcthxq { version: 'PubKey', prefix: 'kaspa', payload: 'qpa8gs8w0quc3ghpx2l2dv30ny0mjuwyaj30xduw92v6mmta7df6uayhcthxq' } node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Reflect.get called on non-object".] {
code: 'ERR_UNHANDLED_REJECTION' }

Node.js v18.19.1

Ligang9 avatar Apr 23 '24 07:04 Ligang9

in typescript branch

  1. wasm-pack build --weak-refs --target nodejs --out-name kaspa --out-dir nodejs/kaspa --features wasm32-sdk
  2. node single-transaction-demo.js --network=mainnet 3.Rejected transaction 97ec6949659f0ddf6a854c3e554769747b8435ef2a6b96d261dadc92fe20265b: transaction 97ec6949659f0ddf6a854c3e554769747b8435ef2a6b96d261dadc92fe20265b is not standard: transaction mass in context (including storage mass) of 315663 is larger than max allowed size of 100000 at module.exports.__wbindgen_error_new (E:\rusty-kaspa\wasm\nodejs\kaspa\kaspa.js:12500:17) at wasm://wasm/022fc6ce:wasm-function[623]:0x23ce3e at wasm://wasm/022fc6ce:wasm-function[2035]:0x42473c at wasm://wasm/022fc6ce:wasm-function[6194]:0x626a16 at __wbg_adapter_89 (E:\rusty-kaspa\wasm\nodejs\kaspa\kaspa.js:295:10) at real (E:\rusty-kaspa\wasm\nodejs\kaspa\kaspa.js:250:20) at node:internal/process/task_queues:140:7 at AsyncResource.runInAsyncScope (node:async_hooks:203:9) at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Please tell me how should I adjust it?

Ligang9 avatar Apr 23 '24 09:04 Ligang9

Transaction information: Transaction: { id: '97ec6949659f0ddf6a854c3e554769747b8435ef2a6b96d261dadc92fe20265b', inputs: [ { previousOutpoint: [Object], signatureScript: '41c676b769448c2c58e7e1fe16a54f7c6f70477ba67aa5deaa846693133bf6d5424c26ce35184591f0c4c06faf1acc093b75aeccac378c9954140f3428b3bdf19201', sequence: 0n, sigOpCount: 1, utxo: [Object] } ], outputs: [ { value: 78810n, scriptPublicKey: [Object] } ], version: 0, lock_time: 0n, gas: 0n, subnetworkId: '0000000000000000000000000000000000000000', payload: '' }

Ligang9 avatar Apr 23 '24 09:04 Ligang9

This is due to KIP-9 restrictions (https://github.com/kaspanet/kips/blob/master/kip-0009.md) - the amount you are sending is too small (the easiest thing is to increase the output amount to be above 0.15...0.2 KAS).

This is due to how this demo script is written - it sends nearly all UTXOs available, which means that you have insufficient total amount in your UTXOs. Add some logs, play around with totals and the transaction amount to see if you can adjust the values.

Also, you should use the transaction generator demo for transaction creation (it will inform such conditions during tx creation).

If you have further issues, I recommend asking on the Kaspa Discord#development channel.

aspect avatar May 27 '24 00:05 aspect