2

I saw a method for sending a transaction to a daemon, but can't find information on how to create and sign a tx using javascript. I can't use the wallet-cli/RPC etc.

1

mymonero has javascript code to create transactions which you can reuse (some surgery needed). Some of it runs binary blobs compiled from C++ though, which may not be what you want. See https://mymonero.com/.

  • I tried use mymonero-core-js, but I saw only SendFunds method. Where I can find examples or where to look. Also, I tried use @xmr-core/xmr-transactions, but I can't find true values for arguments of create_transaction (or examples) – intosKai Oct 17 at 14:53
  • Did you look at the URL I posted ? It should have all the javascript code. I can't go there to get the exact links for you since it blocks Tor. – user36303 Oct 17 at 15:10
  • Are you sure that the transaction is created offline or without requests to mymonero API? I can use only daemon api. – intosKai Oct 17 at 16:36
  • I did not claim that no mymonero API requests are made. However, I am reasonably sure any that are made can be replaced by daemon calls, though I'm not sure how much work is needed. Basically you need outputs to use as inputs. Pretty much all the rest is likely all there in the javascript code. – user36303 Oct 17 at 17:34
1

Creating and signing a Monero transaction in javascript without using the wallet RPC interface is far from trivial. You'd need to:

  1. Have a way of scanning the blockchain to find outputs you own, which is a) infeasible without using a daemon and b) would be ridiculously slow in javascript even with the help of a daemon.

  2. Have all the cryptography code available in javascript, of which there are various pieces scattered over a few different projects, its unlikely you'll find everything you'd need neatly in one project.

  3. Create a javascript implementation of a Monero transaction object (and all its sub objects/types).

  4. Implement the serialization of #3 to its binary form.

  5. Broadcast the binary data to the Monero network.

The daemon and wallet RPC interfaces offer the easiest way to interact with Monero from external code, whatever language one wishes to use.

As @user36303 pointed out, the MyMonero team use a lot of javascript (much of which created from c++), and though they don't use the official wallet RPC interface, they do have their own custom backend and API. So if you are going to embark on the steps above, there will likely be some code of use to you in their repositories.

Using the wallet RPC is significantly simpler - a call to transfer (which can be done offline if the RPC is local).

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.