<p>The <code>result.key_deposit</code> is <code>undefined</code>, which means it is not set to a value (and not <code>null</code> either). <code>BigInt()</code> expects you to provide a valid integer number either as a number or a string. Therefore <code>BigInt()</code> throws an error when you provide <code>undefined</code> instead.</p>
<p>Check what happens in your code before this line to figure out why <code>result.key_deposit</code> doesn't contain a number.</p>
<p>See <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#bigint_coercion" rel="nofollow noreferrer">BigInt coercion</a> for more info on BigInt  errors.</p>
<p>One likely pitfall I can see is that you might not have replaced the <a href="https://blockfrost.io/" rel="nofollow noreferrer">Blockfrost API key</a>:</p>
<pre><code>// set blockfrost endpoint
const lucid = await Lucid.new(
  new Blockfrost(
    &quot;https://cardano-preprod.blockfrost.io/api/v0&quot;,
    &quot;insert you own api key here&quot; // &lt;-- REPLACE THIS WITH A REAL API KEY
  ),
  &quot;Preprod&quot;
);
</code></pre>

CC BY-SA 4.0
2023-06-28T06:19:09.310Z
2023-06-28T06:27:55.407Z
2023-06-28T06:27:55.407Z
eddex
<p>I'm running into the follow Lucid error from Week4 of Plutus pioneer program:</p>
<pre><code>/workspace/code/Week04/lecture# deno run -A lucid-vesting.ts
error: Uncaught (in promise) TypeError: Cannot convert undefined to a BigInt
      keyDeposit: BigInt(result.key_deposit),
                  ^
    at BigInt (&lt;anonymous&gt;)
    at Blockfrost.getProtocolParameters (https://deno.land/x/lucid@0.10.6/src/provider/blockfrost.ts:39:19)
    at async Function.new (https://deno.land/x/lucid@0.10.6/src/lucid/lucid.ts:56:34)
    at async file:///workspace/code/Week04/lecture/lucid-vesting.ts:19:15

</code></pre>
<p>I tried updating the import to use the latest Lucid version, but it didn't help:</p>
<p><code>from &quot;https://deno.land/x/lucid@0.10.6/mod.ts&quot;</code></p>
<p>I'm not sure what these type errors mean</p>

<plutus-pioneer-program><lucid>
Lucid vesting demo
# Lucid vesting demo

(Asked by: username_0 on 2023-06-28)

I'm running into the follow Lucid error from Week4 of Plutus pioneer program:
/workspace/code/Week04/lecture# deno run -A lucid-vesting.ts
error: Uncaught (in promise) TypeError: Cannot convert undefined to a BigInt
      keyDeposit: BigInt(result.key_deposit),
                  ^
    at BigInt ()
    at Blockfrost.getProtocolParameters (https://deno.land/x/lucid@0.10.6/src/provider/blockfrost.ts:39:19)
    at async Function.new (https://deno.land/x/lucid@0.10.6/src/lucid/lucid.ts:56:34)
    at async file:///workspace/code/Week04/lecture/lucid-vesting.ts:19:15


I tried updating the import to use the latest Lucid version, but it didn't help:
from "https://deno.land/x/lucid@0.10.6/mod.ts"
I'm not sure what these type errors mean

**Tags:** plutus-pioneer-program, lucid

---

## 1 answers

### Answer by username_1 on 2023-06-28. Score: 1 | Accepted answer

The result.key_deposit is undefined, which means it is not set to a value (and not null either). BigInt() expects you to provide a valid integer number either as a number or a string. Therefore BigInt() throws an error when you provide undefined instead.
Check what happens in your code before this line to figure out why result.key_deposit doesn't contain a number.
See BigInt coercion for more info on BigInt  errors.
One likely pitfall I can see is that you might not have replaced the Blockfrost API key:
// set blockfrost endpoint
const lucid = await Lucid.new(
  new Blockfrost(
    "https://cardano-preprod.blockfrost.io/api/v0",
    "insert you own api key here" // <-- REPLACE THIS WITH A REAL API KEY
  ),
  "Preprod"
);


---

