DEV Community

Daniel Ioni
Daniel Ioni

Posted on

Monero Wallet RPC Integration: A Complete Guide

Monero Wallet RPC Integration: A Complete Guide
How we integrated Monero wallet RPC with Tari asset tokenization
๐Ÿ“Œ Overview

We built a complete Monero wallet RPC integration for the MyZubster Gateway โ€” a system that tokenizes real-world assets on the Tari blockchain (Monero's Layer 2).

This guide covers:

Wallet RPC setup and configuration

Transaction monitoring

Balance management

Integration with the gateway
Enter fullscreen mode Exit fullscreen mode

๐Ÿ—๏ธ Architecture
text

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MONERO โ”‚
โ”‚ (Privacy Layer) โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ WALLET RPC โ”‚
โ”‚ (Port 18081) โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ–ผ โ–ผ โ”‚
โ”‚ GATEWAY API DASHBOARD โ”‚
โ”‚ (Port 3001) (Port 8080) โ”‚
โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ TOKENIZED ASSETS โ”‚
โ”‚ (MRE, SRE, etc.) โ”‚
โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Setup & Configuration

  1. Install Monero bash

apt update
apt install monero -y

  1. Create a Wallet bash

Create a new wallet

echo -e "password\npassword" | \
monero-wallet-cli \
--generate-new-wallet /root/monero-wallet/gateway-wallet \
--daemon-address node.moneroworld.com:18089

  1. Start Wallet RPC bash

monero-wallet-rpc \
--wallet-file /root/monero-wallet/gateway-wallet \
--password "YOUR_PASSWORD" \
--rpc-bind-port 18081 \
--disable-rpc-login \
--daemon-address node.moneroworld.com:18089 \
--trusted-daemon &

๐Ÿ“ก API Reference
Get Balance
bash

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "get_balance"
}' | jq '.'

Get Address
bash

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "get_address"
}' | jq '.'

Send Transaction
bash

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"destinations": [
{
"address": "RECIPIENT_ADDRESS",
"amount": 1000000000000
}
],
"mixin": 16,
"priority": 1,
"get_tx_key": true
}
}' | jq '.'

List Incoming Transfers
bash

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "get_transfers",
"params": {
"in": true
}
}' | jq '.'

Check Transaction Confirmations
bash

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "get_transfers",
"params": {
"in": true,
"out": true
}
}' | jq '.result.in[0].confirmations'

๐Ÿ”’ Security Best Practices

  1. Password Management

    Store passwords in environment variables

    Use strong passwords (mix of letters, numbers, symbols)

    Never hardcode passwords in scripts

  2. RPC Security
    bash

Enable authentication

monero-wallet-rpc \
--rpc-bind-port 18081 \
--rpc-login username:password \
--wallet-file /path/to/wallet

  1. Firewall Configuration bash

Allow only localhost

ufw allow from 127.0.0.1 to any port 18081

  1. Wallet Backup bash

Backup wallet files

tar -czf wallet-backup.tar.gz /root/monero-wallet/

๐Ÿณ Docker Deployment
Docker Compose Example
yaml

version: '3.8'
services:
monero-wallet:
image: monero:latest
container_name: monero-wallet
command: >
monero-wallet-rpc
--wallet-file /wallet/gateway-wallet
--password YOUR_PASSWORD
--rpc-bind-port 18081
--disable-rpc-login
--daemon-address node.moneroworld.com:18089
--trusted-daemon
ports:
- "18081:18081"
volumes:
- ./monero-wallet:/wallet
restart: unless-stopped

๐Ÿ” Troubleshooting
Common Issues

  1. "No connection to daemon"

Solution: Use a different public node or start your own daemon
bash

Alternative nodes

--daemon-address xmr-node.cakewallet.com:18081
--daemon-address monero.fail:18081

  1. "Invalid password"

Solution: Check password and try again
bash

Reset wallet

rm -f /root/monero-wallet/*.lock

  1. "Not enough money"

Solution: Wait for confirmations (10 blocks = ~20 minutes)
bash

Check unlock status

curl -X POST http://localhost:18081/json_rpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"get_balance"}' \
| jq '.result.unlocked_balance'

  1. "Resource temporarily unavailable"

Solution: Remove lock file
bash

rm -f /root/monero-wallet/*.lock

๐Ÿ“Š Monitoring
Health Check Script
bash

!/bin/bash

check-wallet.sh

RPC_URL="http://localhost:18081/json_rpc"

response=$(curl -s -X POST $RPC_URL \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"get_balance"}')

if echo "$response" | jq -e '.result' > /dev/null; then
echo "โœ… Wallet RPC is running"
balance=$(echo "$response" | jq '.result.balance')
unlocked=$(echo "$response" | jq '.result.unlocked_balance')
echo "Balance: $balance"
echo "Unlocked: $unlocked"
else
echo "โŒ Wallet RPC is not responding"
exit 1
fi

Cron Job for Monitoring
bash

Check every 5 minutes

*/5 * * * * /root/check-wallet.sh >> /var/log/wallet-monitor.log

๐ŸŽฏ Integration with Gateway
.env Configuration
env

Monero Wallet RPC

MONERO_RPC_URL=http://localhost:18081
MONERO_WALLET_ADDRESS=4APG2UXM1XS6aE8XTw397TSPuExwXoh5vd8GgjFDxmaXeWePDbcXdM2CujviKPprW2NczN2WdKKGqLUn1FJ3PSGRSkLnMTG
MONERO_WALLET_PASSWORD=YOUR_PASSWORD
MONERO_RPC_USERNAME=
MONERO_RPC_PASSWORD=
MONERO_NETWORK=mainnet
MONERO_MIN_CONFIRMATIONS=10

Node.js Integration
javascript

// wallet.js
const axios = require('axios');

class MoneroWallet {
constructor(rpcUrl, password) {
this.rpcUrl = rpcUrl;
this.password = password;
}

async getBalance() {
const response = await axios.post(this.rpcUrl, {
jsonrpc: '2.0',
id: '1',
method: 'get_balance'
}, {
headers: { 'Content-Type': 'application/json' }
});
return response.data.result;
}

async sendTransaction(address, amount) {
const response = await axios.post(this.rpcUrl, {
jsonrpc: '2.0',
id: '1',
method: 'transfer',
params: {
destinations: [{ address, amount }],
mixin: 16,
priority: 1,
get_tx_key: true
}
});
return response.data.result;
}
}

module.exports = MoneroWallet;

๐Ÿ“ˆ Performance Metrics
Operation Average Time
Balance check < 100ms
Send transaction 2-5 seconds
Confirmation 2-10 minutes
Full unlock 20-30 minutes
๐Ÿ”ฎ Future Improvements

โ–ก

Multi-wallet support
โ–ก

WebSocket notifications
โ–ก

Advanced analytics
โ–ก

Integration with Tari smart contracts
โ–ก

Automated backup system
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“š Resources

Monero RPC Documentation

Tari Blockchain

Monero Wallet CLI
Enter fullscreen mode Exit fullscreen mode

๐Ÿค Contributing

We welcome contributions! Check our Spiccioli bounty system for paid tasks.

Built with โค๏ธ on Tari ยท Powered by Monero

Monero #Tari #Blockchain #Wallet #RPC #Crypto #DevOps #NodeJS #Docker #Privacy

Top comments (0)