Mogami
  • Home
  • Roadmap & ideas
  • x402 in French
  • Java client SDK
    • Getting started
    • Example client
  • Java server SDK
    • Getting started
    • Example server
    • Configuration
  • Faciliator server
    • Getting started
    • Verifications
  • Learning X402
    • Protocol explanation
      • Get /weather without X-PAYMENT
      • Get /weather with X-PAYMENT
      • Payment verification on server
      • Payment settlement on server
    • X402 hands-on
    • Useful links
  • Contact
    • Email
    • Twitter
Powered by GitBook
On this page
  1. Java server SDK

Getting started

The Mogami x402 Spring Boot Starter adds a micropayment guard to any Spring Boot endpoint. Just annotate a controller method with @X402PaymentRequirements, set your payment information, done!

Here is how to use it:

@X402PaymentRequirements(
        scheme = "exact",
        network = "base-sepolia",
        maximumAmountRequired = "1000",
        payTo = "0x7553F6FA4Fb62986b64f79aEFa1fB93ea64A22b1",
        asset = "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
        extra = {
                @X402PaymentRequirements.ExtraEntry(key = "name", value = "USDC"),
                @X402PaymentRequirements.ExtraEntry(key = "version", value = "2")
        })
@GetMapping("/weather")
public String weather() {
        return "It's sunny!";
}

To use it in your Maven project :

<dependency>
        <groupId>tech.mogami.spring</groupId>
        <artifactId>mogami-x402-spring-boot-starter</artifactId>
        <version>0.1.2</version>
</dependency>

and in your Gradle project:

dependencies {
    implementation 'tech.mogami.spring:mogami-x402-spring-boot-starter:0.1.2'
}

And don't forget to add this parameter : x402.facilitator.base-url=https://x402.org/facilitator to your application.properties file.

PreviousExample clientNextExample server

Last updated 14 days ago