What do I have to do to hash the transaction data using the Javascript SDK? I am using the 10.16.0 version of NodeJS.
As you can see in the screenshot below, I think I’m creating transaction hash using TxBuilder. But I didn’t define any secretKey information. Is this a problem?
@sistemkoin-mahsum Hey,
As i can see you already prepare the hash for spend transaction, the next step will be to wrap this transaction into signedTx which require the secretKey to produce the signature.
To do that you need to init MemoryAccount stamp and use signTransaction fn.
This is the implementation of this fn
can you try to narrow your code down to the essential part that creates the error, I can’t really see what wrong, eventually there is some issue how you implement the MemoryAccount.
The error occurs when the MemoryAccount function is called. I guess when calling MemoryAccount function, publicKey is not defined in “const secrets = new WeakMap()”. In the first screenshot below, you can see the line where the error occurred. In the example in the second screenshot, you can see the output of the MemoryAccount() function. Output does not contain keypair information.
can you try just using the Universal stamp of the sdk and a simplified keypair, where you don’t use memory account, just pass keypair as object directly to the sdk initialization?
also for testnet the networkId needs to be ae_uat.
@nduchak.chain The parameters are correct. publicKey starts with “ak_”. But because I tried to get the private key value from the wrong property, an error occurred. I’d fix the problem.
Now I’ve mentioned above with the error 404 occurs. Error :
Error: Request failed with status code 404
at createError (/projects/node_modules/axios/lib/core/createError.js:16:15)
at settle (/projects/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/projects/node_modules/axios/lib/adapters/http.js:237:11)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
The error was from the URL. I fixed the URL. Now the error I mentioned below occurs.
ReferenceError: window is not defined
at Object.init (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:153914)
at /projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:76239
at u (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:16715)
at Generator._invoke (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:16503)
at Generator.t.(anonymous function) [as next] (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:17137)
at n (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:2050)
at c (/projects/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:2260)
at process._tickCallback (internal/process/next_tick.js:68:7)
I’m creating the Wallet function constant as follows.
{
"code": "Error",
"message": "While calling postTransaction (body), POST to http://MY_NODE_URL:3013/v2/transactions failed with 400: Invalid tx",
"stack": "Error: While calling postTransaction (body), POST to http://MY_NODE_URL:3013/v2/transactions failed with 400: Invalid tx\n at Object.<anonymous> (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:93079)\n at u (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:16715)\n at Generator._invoke (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:16503)\n at Generator.t.(anonymous function) [as throw] (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:17137)\n at n (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:2050)\n at s (/MY_PROJECT_DIR/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:2296)\n at process._tickCallback (internal/process/next_tick.js:68:7)"
}
our node’s network_id is au_mainnet. But when I try to create a transaction, I wait about 1.5 minutes on the line I marked in the first screenshot. The application stops before any errors occur.
When I tried to create this transaction a few hours ago, I was able to create a transaction. Public and secret key information is correct. url and internalUrl information is also correct.