Swap Permit2 Build
Build the final Permit2 transaction from a prepared plan and payer signature.
Attach a payer signature to an unexpired prepared plan and return its executable transaction. This is the second Permit2 request; SDK method: swapPermit2Build(). The saved route and roles are preserved without requoting. Send the signature only in the JSON body. Building does not broadcast the transaction.
Compatibility alias: /router/swap/build. Production deployment of the new endpoint has not been verified.
Quote ID returned by delegated preparation.
^0x[0-9a-fA-F]{64}$Payer signature over the returned Permit2 witness typed_data. 64-byte compact or 65-byte ECDSA. Send only in the JSON body.
^0x(?:[0-9a-fA-F]{128}|[0-9a-fA-F]{130})$Application success (code=200) or application error (code!=200). Business errors may still have HTTP status 200; inspect the JSON code.
Malformed query or request rejected by HTTP extraction. Body may be plain text rather than an application envelope.
Build request body exceeds the 4 KiB service limit.
Unsupported Content-Type. Send application/json.
Invalid JSON body or field types; extractor response may be plain text.
Unhandled service failure.
Service-wide rate limit / circuit breaking. Retry with backoff.
# Use QUOTE_ID from the successful prepare response and PAYER_SIGNATURE
# from the payer signature over that response's Permit2 witness typed_data.
# These environment variables are placeholders for actual prepared values.
: "${QUOTE_ID:?Set QUOTE_ID from the prepare response}"
: "${PAYER_SIGNATURE:?Set PAYER_SIGNATURE to the payer witness signature}"
curl --fail-with-body --silent --show-error \
--request POST 'https://api.peach.ag/router/swap/permit2/build' \
--header 'Content-Type: application/json' \
--data "{\"quote_id\":\"$QUOTE_ID\",\"payer_signature\":\"$PAYER_SIGNATURE\"}"
# Do not log the signature. Build does not broadcast the transaction.
{
"code": 200,
"msg": "Success",
"data": {
"quote_id": "text",
"payer": "text",
"executor": "text",
"recipient": "text",
"plan_hash": "text",
"execution_mode": "PERMIT2_WITNESS",
"execution_status": "TRANSACTION_READY",
"gas": 1,
"tx": {
"to": "text",
"data": "text",
"value": "text",
"entrypoint": "executePlan",
"amount_out_min": "text"
}
}
}Integration notes
Send a 64-byte compact or 65-byte ECDSA signature only in the JSON body. On-chain execution verifies authorization. Review the built terms and submit the returned transaction as executor before its deadline; build does not broadcast.
Expired artifacts or exceeded build-attempt limits require fresh preparation and a new signature.
Check both the HTTP status and JSON code; a business error may use HTTP 200. See Error Codes for recovery guidance. Invalid query or body extraction may return plain text instead of the JSON envelope.
Last updated
Was this helpful?