Skip to content

Examples

Every library has the same data model and API, so the examples read the same in every language: pick a language in any tab and all the pages follow. They run against a stagenet node and a monero-wallet-rpc server on your machine.

Warning

Wallets handle real funds. Develop against regtest, stagenet or testnet, and never log or commit a seed or a private key.

What is in the examples

Get a library

Language How to get it
Python Prebuilt .deb and wheel packages in the releases
Java Gradle or Maven, or build it from source
Kotlin Build it from source and publish it with ./gradlew publishToMavenLocal, it is not in a repository yet
C# Monero.NET and Monero.Native, build them from source, they are not on nuget.org yet
C++ Build it from source with CMake
C Build it from source, as a shared or a static library

Run a node and a wallet server

The RPC clients need a monerod and a monero-wallet-rpc to talk to. docker-monero-rpc has a compose file that starts both on stagenet:

git clone https://github.com/libmonero/docker-monero-rpc
cd docker-monero-rpc
docker compose -f examples/docker-compose.yml up -d
Server URL Login
monerod http://localhost:38081 superuser / abctesting123
monero-wallet-rpc http://localhost:38083 rpc_user / abc123

The node has to download the stagenet chain the first time, which takes a while. To try the code without waiting, use the regtest compose file, and take the ports and the logins from it.

A native wallet, the ones with Full and Keys in the name, runs in your process and needs no wallet server. A full wallet connects to the daemon, and a keys wallet needs nothing.

Handle errors

A call that fails throws an error, in every language but C, where it returns MONERO_ERROR. The examples leave the checks out, to stay short. See Errors for how to catch them, read the code of an RPC error, and check before you call.

Go further

  • Libraries has the repository of every language, with its own sample code, build instructions and tests.
  • The data model and API specification shows every type and function with diagrams, and applies to every language.
  • The monero-python API reference documents the wallet and daemon interfaces, and its names translate to the other languages.