diff --git a/client/transactions.go b/client/transactions.go index 57690a9..e19abe4 100644 --- a/client/transactions.go +++ b/client/transactions.go @@ -117,3 +117,22 @@ func (c *Client) TransactionOutputsFromReferences( return &transactionOutputsFromReferences, nil } + +func (c *Client) EvaluateTx(txCbor string, AdditionalUtxos ...string) ([]models.RedeemerEvaluation, error) { + url := "/transactions/evaluate" + body := models.EvaluateTx{ + Cbor: txCbor, + AdditionalUtxos: AdditionalUtxos, + } + resp, err := c.post(url, body) + if err != nil { + return nil, err + } + defer resp.Body.Close() + var redeemerEvals []models.RedeemerEvaluation + err = json.NewDecoder(resp.Body).Decode(&redeemerEvals) + if err != nil { + return nil, err + } + return redeemerEvals, nil +} diff --git a/models/transactions.go b/models/transactions.go index 5bde671..35226ab 100644 --- a/models/transactions.go +++ b/models/transactions.go @@ -65,3 +65,21 @@ type TransactionOutputsFromReferences struct { LastUpdated utils.LastUpdated `json:"last_updated"` NextCursor string `json:"next_cursor"` } + +type EvaluateTx struct { + Cbor string `json:"cbor"` + AdditionalUtxos []string `json:"additional_utxos"` +} + +type ExecutionUnits struct { + Mem int64 `json:"Mem"` + Steps int64 `json:"Steps"` +} + +type RedeemerEvaluation struct { + ExUnits ExecutionUnits `json:"ex_units"` + RedeemerIndex int `json:"redeemer_index"` + RedeemerTag string `json:"redeemer_tag"` +} + +type EvaluateTxResponse []RedeemerEvaluation