Oracle
Record Price Attestation
Record a signed price produced by a key outside this instance
POST
/
lending-external-securities-v2
/
api
/
markets
/
{marketId}
/
price-attestation
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/price-attestation" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"price": "105400000",
"timestamp": 1718445600,
"validUntil": 1718445900,
"signature": "0x5f1c3a9e0b7d24c68f1e3a5b7c9d0e2f4a6b8c0d1e3f5a7b9c1d3e5f7a9b0c2d4e6f8a1b3c5d7e9f0a2b4c6d8e0f1a3b5c7d9e1f3a5b7c9d0e2f4a6b8c0d1e3f1b"
}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/price-attestation`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
price: signed.price,
timestamp: signed.timestamp,
validUntil: signed.validUntil,
signature
})
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"attestation": {
"id": "clx4k2p9e0001m8tq3v7h5z2a",
"price": "105400000",
"priceDecimal": "105.4",
"attestedAt": 1718445600,
"validUntil": 1718445900,
"signer": "0x9c1e57a2d0b34f86e7a15c9d2b4f60e38a7d4b70",
"source": "API",
"pushedTxHash": null,
"pushedAt": null,
"createdAt": "2024-06-15T10:00:04.512Z"
},
"alreadyRecorded": false
}
}
{
"success": false,
"error": {
"code": "SIGNATURE_NOT_ACCEPTED",
"message": "The oracle does not accept this signature. It is expired, malformed, or signed by a key the oracle has not authorized."
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid attestation payload",
"details": [
{ "field": "signature", "message": "Invalid" }
]
}
}
Records a price signature that a key outside this instance produced, so it joins the market’s attested price history. It is the counterpart to Sign Price for a price signer that keeps its key in its own environment: sign the returned payload there, then post the result here.
The oracle is asked to accept the signature before anything is written, so the history never holds a signature nobody verified. Recording writes nothing on-chain and moves no price.
A recorded attestation has two uses. It appears in the
signed list on Get Oracle History, with pushedTxHash stamped once the price lands. A later Sync Oracle Price of exactly that price can also submit it, so any wallet may broadcast the push. That works only while the attestation is unexpired, unpushed, dated after the oracle’s current price and at most 15 minutes old.
The oracle’s acceptance covers the signature, the signer, expiry and age. It does not cover the deviation limit, so a recorded attestation can still revert when submitted.
Path Parameters
string
required
Body Parameters
string
required
Price in base units as an integer string, exactly as signed. Must be greater than zero.
integer
required
The signed timestamp in unix seconds. Must be a positive integer.
integer
required
The signed expiry in unix seconds. Must be a positive integer later than
timestamp.string
required
The 65-byte EIP-712 signature, as 0x followed by 130 hex characters.
Response Fields
object
Show child attributes
Show child attributes
object
The recorded attestation.
Show child attributes
Show child attributes
string
Attestation ID.
string
The price in base units.
string
The same price as a decimal string at the borrow asset’s decimals.
integer
The signed timestamp, in unix seconds.
integer
The signed expiry, in unix seconds.
string
The key the oracle recovered from the signature.
string
API when recorded through this endpoint, APP when recorded through the Trusset app.string
The transaction that landed this price on the oracle, or
null until it lands.string
When that transaction was mined, or
null.string
When the attestation was recorded.
boolean
true when this signature was already recorded for the market. The existing record is returned and nothing new is written.curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/price-attestation" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"price": "105400000",
"timestamp": 1718445600,
"validUntil": 1718445900,
"signature": "0x5f1c3a9e0b7d24c68f1e3a5b7c9d0e2f4a6b8c0d1e3f5a7b9c1d3e5f7a9b0c2d4e6f8a1b3c5d7e9f0a2b4c6d8e0f1a3b5c7d9e1f3a5b7c9d0e2f4a6b8c0d1e3f1b"
}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/price-attestation`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
price: signed.price,
timestamp: signed.timestamp,
validUntil: signed.validUntil,
signature
})
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"attestation": {
"id": "clx4k2p9e0001m8tq3v7h5z2a",
"price": "105400000",
"priceDecimal": "105.4",
"attestedAt": 1718445600,
"validUntil": 1718445900,
"signer": "0x9c1e57a2d0b34f86e7a15c9d2b4f60e38a7d4b70",
"source": "API",
"pushedTxHash": null,
"pushedAt": null,
"createdAt": "2024-06-15T10:00:04.512Z"
},
"alreadyRecorded": false
}
}
{
"success": false,
"error": {
"code": "SIGNATURE_NOT_ACCEPTED",
"message": "The oracle does not accept this signature. It is expired, malformed, or signed by a key the oracle has not authorized."
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid attestation payload",
"details": [
{ "field": "signature", "message": "Invalid" }
]
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | The body does not match the schema, the price is zero, or validUntil does not follow timestamp. The schema refusal says Invalid attestation payload and lists details |
NO_ORACLE | 400 | The market records no oracle address |
MISSING_MARKET_ID | 400 | marketId is longer than 100 characters |
MARKET_NOT_FOUND | 404 | No market with this ID on your instance |
EXTERNAL_FEED_ACTIVE | 409 | The market’s oracle reads an external feed and takes no attested price |
FIXED_PRICE_ACTIVE | 409 | The market has a fixed price, and its oracle refuses every signed price, so there is no attestation to record. The price authority marks a fixed price down through Sync Oracle Price |
SIGNATURE_NOT_ACCEPTED | 422 | The oracle rejects the signature: it is expired, dated in the future or older than maxPriceAge, does not recover, or recovers to an unauthorized key |
ATTESTATION_FAILED | 500 | The attestation could not be recorded and no more specific code applied |
ORACLE_UNREACHABLE | 503 | The oracle could not be reached to verify the signature. Nothing was recorded |
PRICE_STATE_UNAVAILABLE | 503 | Whether the market’s oracle holds a fixed price could not be read. Nothing was recorded |
⌘I
curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/markets/{marketId}/price-attestation" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"price": "105400000",
"timestamp": 1718445600,
"validUntil": 1718445900,
"signature": "0x5f1c3a9e0b7d24c68f1e3a5b7c9d0e2f4a6b8c0d1e3f5a7b9c1d3e5f7a9b0c2d4e6f8a1b3c5d7e9f0a2b4c6d8e0f1a3b5c7d9e1f3a5b7c9d0e2f4a6b8c0d1e3f1b"
}'
const res = await fetch(
`https://api.trusset.org/lending-external-securities-v2/api/markets/${marketId}/price-attestation`,
{
method: 'POST',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
price: signed.price,
timestamp: signed.timestamp,
validUntil: signed.validUntil,
signature
})
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"attestation": {
"id": "clx4k2p9e0001m8tq3v7h5z2a",
"price": "105400000",
"priceDecimal": "105.4",
"attestedAt": 1718445600,
"validUntil": 1718445900,
"signer": "0x9c1e57a2d0b34f86e7a15c9d2b4f60e38a7d4b70",
"source": "API",
"pushedTxHash": null,
"pushedAt": null,
"createdAt": "2024-06-15T10:00:04.512Z"
},
"alreadyRecorded": false
}
}
{
"success": false,
"error": {
"code": "SIGNATURE_NOT_ACCEPTED",
"message": "The oracle does not accept this signature. It is expired, malformed, or signed by a key the oracle has not authorized."
}
}
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid attestation payload",
"details": [
{ "field": "signature", "message": "Invalid" }
]
}
}
