<p>You probably already did, but check that you are actually passing the utxos to the tx, and check that the datum is the right one, the datum seems to be hash or its just a bytestring? how does quering the utxo on cli or looking for the datum in explorers look?</p>
<p>It seems no valid utxo is available for spending or the validator itself its wrong.</p>
<p>take a look at this post that seems to be dealing with a similar problem.</p>
<p><a href="https://cardano.stackexchange.com/questions/11027/lucid-error-end-of-input-in-bytes">Lucid Error &quot;End of input in bytes&quot;</a></p>
<p>how are you importing your validators cbor into Lucid?, you can use Lucid blueprint parser examples, or if you where using a CLI ready json file (created with aiken blueprint convert) you can copy paste the cborhex, or import it and parse it.</p>

CC BY-SA 4.0
2024-04-30T22:51:05.230Z
thanks, I added to the question how I import the validator from the aiken build json - method shown in an aiken example.
and here is tha datum which seem correct to me:
https://preview.cexplorer.io/datum/a105195230a69720e9ea5cc755f03e6ce6af7ac8c579857d5de32739ecb6b75f
user3755529
CC BY-SA 4.0
2024-04-29T01:50:46.360Z
2024-04-29T01:50:46.360Z
Roberto Cerrud
<p>I get this error when trying to unlock funds from an UTXO in a contract address:</p>
<pre><code>Uncaught (in promise) &quot;Redeemer (Spend, 0): Attempted to apply a non-function:\n\nCon(\n    Unit,\n)\n\nExBudget {\n    mem: 12788611,\n    cpu: 9492522265,\n}\n\n&quot;
</code></pre>
<p>is there any problem in the following code?</p>
<pre class="lang-js prettyprint-override"><code>async function unlock(ref: OutRef, from: SpendingValidator): Promise&lt;TxHash&gt; {
  const [utxo] = await lucid.utxosByOutRef([ref]);

  const tx = await lucid
    .newTx()
    .collectFrom( [utxo], Data.to(new Constr(0,[])) )
    .addSigner(await lucid.wallet.address())
    .attachSpendingValidator(from)
    .complete();

  const signedTx = await tx
    .sign()
    .complete();
 
  return signedTx.submit();
}
</code></pre>
<p>here is how I take the validator:</p>
<pre class="lang-js prettyprint-override"><code>const validator = await readValidator();

async function readValidator(): Promise&lt;SpendingValidator&gt; {
  const validator = JSON.parse(await Deno.readTextFile(&quot;plutus.json&quot;)).validators[0];
  return {
    type: &quot;PlutusV2&quot;,
    script: toHex(cbor.encode(fromHex(validator.compiledCode))), 
    // some alchemy with Uint8Array and other codes that returns pretty much initial thing but a little different
  };
}
</code></pre>

CC BY-SA 4.0
2024-04-26T03:55:24.927Z
What data structure is specting the Validator? What type is the redeemer? what language you used to make the validator?
Roberto Cerrud
CC BY-SA 4.0
2024-04-27T19:06:22.570Z
The redeemer is Void, while the datum is simply a ByteArray `type Datum {hex: ByteArray}` `validator {  fn check(datum: Datum, _redeemer: Void) -> Bool {complexfunc(datum.hex)}`and I used Aiken.
Could it be that the problem resides in the function that processes the Datum's ByteArray inside the Aiken validator? rather than a problem with Lucid?
Although when I test the validator in Aiken it works fine.
user3755529
CC BY-SA 4.0
2024-04-28T09:19:25.190Z
I tried just with a simple equality as validator and I still get the same error. this is the utxo I am trying to use: `{
  txHash: "a183...",
  outputIndex: 0,
  assets: { lovelace: 10000000n },
  address: "addr_test1wr...",
  datumHash: undefined,
  datum: "d8799f43849480ff",
  scriptRef: undefined
}`
so it shouldn't be related to my validator, but an error related to Lucid code but then it is so simple and boilerplate that I don't really know where to look anymore.
user3755529
<lucid><redeemer><inline-datum>
Error Applying Redeemer Lucid
# Error Applying Redeemer Lucid

(Asked by: username_0 on 2024-04-20)

I get this error when trying to unlock funds from an UTXO in a contract address:
Uncaught (in promise) "Redeemer (Spend, 0): Attempted to apply a non-function:\n\nCon(\n    Unit,\n)\n\nExBudget {\n    mem: 12788611,\n    cpu: 9492522265,\n}\n\n"

is there any problem in the following code?
async function unlock(ref: OutRef, from: SpendingValidator): Promise {
  const [utxo] = await lucid.utxosByOutRef([ref]);

  const tx = await lucid
    .newTx()
    .collectFrom( [utxo], Data.to(new Constr(0,[])) )
    .addSigner(await lucid.wallet.address())
    .attachSpendingValidator(from)
    .complete();

  const signedTx = await tx
    .sign()
    .complete();
 
  return signedTx.submit();
}

here is how I take the validator:
const validator = await readValidator();

async function readValidator(): Promise {
  const validator = JSON.parse(await Deno.readTextFile("plutus.json")).validators[0];
  return {
    type: "PlutusV2",
    script: toHex(cbor.encode(fromHex(validator.compiledCode))), 
    // some alchemy with Uint8Array and other codes that returns pretty much initial thing but a little different
  };
}

**Tags:** lucid, redeemer, inline-datum
> **Comments:**
> **username_1**: What data structure is specting the Validator? What type is the redeemer? what language you used to make the validator?  
> **username_0**: The redeemer is Void, while the datum is simply a ByteArray `type Datum {hex: ByteArray}` `validator {  fn check(datum: Datum, _redeemer: Void) -> Bool {complexfunc(datum.hex)}`and I used Aiken. Could it be that the problem resides in the function that processes the Datum's ByteArray inside the Aiken validator? rather than a problem with Lucid? Although when I test the validator in Aiken it works fine.  
> **username_0**: I tried just with a simple equality as validator and I still get the same error. this is the utxo I am trying to use: `{   txHash: "a183...",   outputIndex: 0,   assets: { lovelace: 10000000n },   address: "addr_test1wr...",   datumHash: undefined,   datum: "d8799f43849480ff",   scriptRef: undefined }` so it shouldn't be related to my validator, but an error related to Lucid code but then it is so simple and boilerplate that I don't really know where to look anymore.  

---

## 1 answers

### Answer by username_1 on 2024-04-29. Score: 1

You probably already did, but check that you are actually passing the utxos to the tx, and check that the datum is the right one, the datum seems to be hash or its just a bytestring? how does quering the utxo on cli or looking for the datum in explorers look?

It seems no valid utxo is available for spending or the validator itself its wrong.

take a look at this post that seems to be dealing with a similar problem.

[Lucid Error "End of input in bytes"](https://cardano.stackexchange.com/questions/11027/lucid-error-end-of-input-in-bytes)

how are you importing your validators cbor into Lucid?, you can use Lucid blueprint parser examples, or if you where using a CLI ready json file (created with aiken blueprint convert) you can copy paste the cborhex, or import it and parse it.

> **Comments:**
> **username_0**: thanks, I added to the question how I import the validator from the aiken build json - method shown in an aiken example. and here is tha datum which seem correct to me: https://preview.cexplorer.io/datum/a105195230a69720e9ea5cc755f03e6ce6af7ac8c579857d5de32739ecb6b75f  

---

