I'm trying to develop an application with react native to have access to monero accounts and then make some operations like get the balance, transfer and receive XMR. I found some javascript libs in the github, but some of them are deprecated, missing methods or poor documentation. I would like some help to make something like in the photo. A lib recommendation, example codes, etc.
1 Answer
Monero-Javascript (https://github.com/monero-ecosystem/monero-javascript) is actively maintained and easy to use. They have some example code in their repository for how to send a transaction:
const monerojs = require("monero-javascript");
let walletRpc = await monerojs.connectToWalletRpc("http://localhost:38084", "rpc_user", "abc123");
await walletRpc.openWallet("sample_wallet_rpc", "supersecretpassword123");
let createdTx = await walletRpc.createTx({
accountIndex: 0,
address: await walletFull.getAddress(1, 0),
amount: "250000000000", // send 0.25 XMR (denominated in atomic units)
relay: false // create transaction and relay to the network if true
});
let fee = createdTx.getFee(); // "Are you sure you want to send... ?"
await walletRpc.relayTx(createdTx); // relay the transaction
Good luck!