Getting started

The Mogami Java Server SDK lets you transform any API into a pay-per-call service powered by x402. With a single Spring Boot annotation, you can enforce stablecoin payments.

Here is how to use it on a simple REST service:

@X402PayUSDC(amount = "3") // 3 USDC
@GetMapping("/weather")
public String weather() {
        return "It's sunny!";
}

You can have more parameters:

    @X402PayUSDC(
            amount = "0.01",
            payTo = "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
            network = "base-sepolia",
            description = "Access to protected content",
            maximumTimeoutSeconds = 300,
            outputSchema = """
                    {
                      "input": {
                        "discoverable": true,
                        "method": "GET",
                        "type": "http"
                      }
                    }
                    """
    )
@GetMapping("/weather")
public String weather() {
        return "It's sunny!";
}

To use our annotation in your spring boot project, edit your maven project and add:

or in your Gradle project:

Last updated