Intents API

The Intents API is an JSON-RPC API facilitates intent publication, intent refinement, and data queries.

Note: The request bodies in these docs always refer to the expected structure of the params field of a valid JSON-RPC payload. This is to avoid duplicating the same standard JSON-RPC information for every supported RPC method. Every HTTP request body calling the Intents JSON-RPC API should format HTTP body using the below top-level structure. The request body for each specific endpoint will solely denote the expected structure of the inner params field. The method field will also be specified in each specific endpoint documentation.

Name
Type
Description

jsonrpc

string

json-rpc version (always "2.0")

method

string

The RPC method to call

params

string[]

The payload associated with the RPC method

id

number

The id of this RPC request

A note on signatures

Some RPC methods require a signature as well. When a signature is required for a specific endpoint, it will be flagged as such. If the endpoint is a signature-only endpoint, then the JSON-RPC params

API Endpoints:

  1. Request Refinement

  2. Check Refinement Status


Publish Intent

POST <medusa_rpc_url>

Publishes an intent to Medusa.

JSON-RPC Method: "proposeIntent"

Signature required

Headers

content-type

application/json

Body (JSON-RPC Params)

Name
Type
Description

intent

Intent

The intent object to publish

signature

string

The intent author's signature

Intent Payload

The intent field of the request should look like so:

Name
Type
Description

author

string

Address of the intent author

ttl

number

The deadline to fill the intent

nonce

number

An author-specific nonce to ensure intent uniqueness.

srcMToken

string

Address of an mToken owned by the author that the author wishes to trade

srcAmount

number

The amount of srcMToken that the author wishes to sell

Outcome

JSON

The Outcome struct

Example Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "proposeIntent",
  "params": {
      "intent": {
        "author": 0xkhalanian,
        "ttl": 1000000000000,
        "nonce": 1,
        "srcMToken": 0xethUsdcMToken,
        "srcAmount": 100e18,
        "outcome": {
          "mTokens": [0xethDaiMToken],
          "mAmounts": [100e18],
          "outcomeAssetStructure": "AnySingle",
          "fillStructure": "Exactly"
        }
      },
      "signature": 0x...
   } 
}

Get Intent Status

POST /<medusa rpc url>

Get the status of a previously published intent.

JSON-RPC Method: "getIntentStatus"

Headers

Name
Value

Content-Type

application/json

Body (JSON-RPC Params)

The params field of the JSON-RPC payload is a list of intent IDs.

Example Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getIntentStatus",
  "params": [intentId]
}

Last updated