Derive a template's source
curl --request POST \
--url https://gateway.molpha.io/v1/data/derive \
--header 'Content-Type: application/json' \
--data '
{
"params": {},
"source": {},
"template": "token.supply"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({params: {}, source: {}, template: 'token.supply'})
};
fetch('https://gateway.molpha.io/v1/data/derive', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://gateway.molpha.io/v1/data/derive"
payload = {
"params": {},
"source": {},
"template": "token.supply"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.molpha.io/v1/data/derive"
payload := strings.NewReader("{\n \"params\": {},\n \"source\": {},\n \"template\": \"token.supply\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"canonical": "<string>",
"chain": "<string>",
"facts": {},
"layout": [
{}
],
"mode": "exact",
"params": {},
"source": {},
"sourceId": "<string>",
"template": "token.supply@1"
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}Molpha Data API
Derive a template's source
Expands a template and its parameters into the canonical source and its sourceId, or checks a raw source. Facts a template reads from chain (a token’s decimals, a pool’s tokens) are read by two nodes that must agree, and written into the source as constants; the gateway itself reads no chain. Nothing is signed or charged: send the source to POST /v1/round/execute or /v1/x402/execute for a signed value. Rate-limited per client address (429).
POST
/
v1
/
data
/
derive
Derive a template's source
curl --request POST \
--url https://gateway.molpha.io/v1/data/derive \
--header 'Content-Type: application/json' \
--data '
{
"params": {},
"source": {},
"template": "token.supply"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({params: {}, source: {}, template: 'token.supply'})
};
fetch('https://gateway.molpha.io/v1/data/derive', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://gateway.molpha.io/v1/data/derive"
payload = {
"params": {},
"source": {},
"template": "token.supply"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://gateway.molpha.io/v1/data/derive"
payload := strings.NewReader("{\n \"params\": {},\n \"source\": {},\n \"template\": \"token.supply\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"canonical": "<string>",
"chain": "<string>",
"facts": {},
"layout": [
{}
],
"mode": "exact",
"params": {},
"source": {},
"sourceId": "<string>",
"template": "token.supply@1"
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}{
"error": {
"code": "PARAM_INVALID",
"input": "<string>",
"message": "<string>",
"stage": "<string>"
}
}Body
application/json
Template with parameters, or a source