Skip to content

Commit c7460c8

Browse files
Merge pull request #539 from Anastasia-Labs/docs-update-2
docs: bring tab structure, extend descriptions, remove redundancies
2 parents dfbd1ae + ccf9f2f commit c7460c8

16 files changed

Lines changed: 805 additions & 861 deletions

docs/pages/documentation/_meta.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"type": "separator"
1818
},
1919

20+
"under-the-hood": "Under The Hood",
21+
2022
"examples": {
2123
"title": "Examples",
2224
"theme": {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"instantiate-evolution": "Instantiate Evolution",
3-
"choose-wallet": "Choose Wallet",
4-
"first-transaction": "Your First Transaction",
5-
"under-the-hood": "Under The Hood"
3+
"wallet-management": "Wallet Management",
4+
"first-transaction": "First Transaction"
65
}

docs/pages/documentation/core-concepts/first-transaction.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,27 @@ const tx = await lucid
2828
const signedTx = await tx.sign.withWallet().complete();
2929
```
3030

31-
You could also choose to sign the transaction with a private key:
31+
<Callout type="info">
32+
You could also choose to sign the transaction with a private key:
3233

33-
```typescript
34-
const signedTx = await tx.sign.withPrivateKey(privateKey).complete();
35-
```
34+
```typescript
35+
const signedTx = await tx.sign.withPrivateKey(privateKey).complete();
36+
```
37+
</Callout>
3638

3739
### Submit
3840

3941
Lastly we submit the transaction:
4042

4143
```typescript
4244
const txHash = await signedTx.submit();
43-
console.log(txHash);
4445
```
4546

4647
</Steps>
4748

48-
<Callout>
49+
<Callout type="warning">
4950
Remember to select a wallet before attempting to build and submit
50-
transactions. The wallet selection methods we discussed in previous section
51-
**[Core Concept 2: Choose Wallet](./core-concepts/choose-wallet)** should be implemented before building the
52-
transaction.
51+
transactions. Wallet selection discussed in [**Core Concept 2: Choose Wallet**](./wallet-management) should be implemented before attempting to build and submit transactions.
5352
</Callout>
5453

5554
## Putting everything together
@@ -59,7 +58,7 @@ import { Lucid, Blockfrost } from "@lucid-evolution/lucid";
5958

6059
// Initialize Lucid with a provider
6160
const lucid = await Lucid(
62-
new Blockfrost("https://cardano-preprod.blockfrost.io/api/v0", "<projectId>"),
61+
new Blockfrost("https://cardano-preprod.blockfrost.io/api/v0", "<blockfrost-api-key>"),
6362
"Preprod"
6463
);
6564

Lines changed: 114 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
import { Callout, Steps, Tabs } from "nextra/components";
22

3-
# Instantiate Lucid
3+
# Instantiating Lucid Evolution
44

5-
Lucid Evolution is a library for transaction building and designing the way you want to frame your off-chain. It can be used with or without a provider or a certain network for different purposes. The library supports the `Mainnet`, `Preprod`, `Preview` and `Custom` networks
5+
Lucid Evolution is a transaction building framework for Cardano which provides flexible off-chain development patterns. The library is designed with modularity in mind, allowing you to:
66

7-
To be able to query UTxOs, datums, and protocol parameters, you need to choose a provider and a provider is a service that allows Lucid Evolution to interact with the Cardano blockchain.
7+
- Build and simulate transactions
8+
- Work with different Cardano networks (Mainnet, Preprod, Preview, or Custom networks)
9+
- Choose from multiple provider options for blockchain interaction
810

9-
## Provider selection
11+
## Provider
12+
13+
To interact with the Cardano blockchain (querying UTxOs, datums, or protocol parameters), you'll need to configure a provider. Providers are chain indexing services that offer API access to blockchain data. Lucid Evolution supports several providers:
14+
15+
<Callout type="info">
16+
While a provider is required for blockchain queries, you can still use Lucid Evolution's transaction building features without one.
17+
</Callout>
18+
19+
### Provider selection
1020

1121
You can choose one of the following providers to use with Lucid Evolution
1222

13-
### Blockfrost
23+
<Tabs items={['Blockfrost', 'Kupmios', 'Maestro', 'Koios', 'YACI DevKit', 'UTxORPC']}>
24+
<Tabs.Tab>
1425

1526
```typescript
1627
import { Lucid, Blockfrost } from "@lucid-evolution/lucid";
1728

1829
const lucid = await Lucid(
19-
new Blockfrost("https://cardano-preprod.blockfrost.io/api/v0", "<projectId>"),
30+
new Blockfrost("https://cardano-preprod.blockfrost.io/api/v0", "<blockfrost-api-key>"),
2031
"Preprod"
2132
);
2233
```
2334

24-
---
35+
</Tabs.Tab>
2536

26-
### Kupmios
37+
<Tabs.Tab>
2738

2839
```typescript
2940
import { Lucid, Kupmios } from "@lucid-evolution/lucid";
@@ -37,29 +48,29 @@ const lucid = await Lucid(
3748
);
3849
```
3950

40-
**with API keys**
51+
<Callout type="info">
52+
**If you have API keys**
4153

42-
```typescript
43-
const lucid = await Lucid(
44-
new Kupmios(
45-
"http://localhost:1442",
46-
"http://localhost:1337",
47-
{
48-
kupoHeader: { "priv-api-key": "<kupo-api-key>" }, // for example: "dmtr-api-key": "<kupo-api-key>"
49-
ogmiosHeader: { "priv-api-key": "<ogmios-api-key>" }
50-
}
51-
),
54+
```typescript
55+
const lucid = await Lucid(
56+
new Kupmios("http://localhost:1442", "http://localhost:1337", {
57+
kupoHeader: { "priv-api-key": "<kupo-api-key>" }, // for example: "dmtr-api-key": "<kupo-api-key>"
58+
ogmiosHeader: { "priv-api-key": "<ogmios-api-key>" },
59+
}),
5260
"Preview"
5361
);
5462
```
5563

64+
</Callout>
65+
5666
<Callout type="info">
57-
Kupmios is a mix of [Ogmios](https://ogmios.dev/) and [Kupo](https://cardanosolutions.github.io/kupo/).
67+
Kupmios is a mix of [Ogmios](https://ogmios.dev/) and
68+
[Kupo](https://cardanosolutions.github.io/kupo/).
5869
</Callout>
5970

60-
---
71+
</Tabs.Tab>
6172

62-
### Maestro
73+
<Tabs.Tab>
6374

6475
```typescript
6576
import { Lucid, Maestro } from "@lucid-evolution/lucid";
@@ -74,9 +85,9 @@ const lucid = await Lucid(
7485
);
7586
```
7687

77-
---
88+
</Tabs.Tab>
7889

79-
### Koios
90+
<Tabs.Tab>
8091

8192
```typescript
8293
import { Lucid, Koios } from "@lucid-evolution/lucid";
@@ -87,120 +98,107 @@ const lucid = await Lucid(
8798
);
8899
```
89100

90-
**with bearer token**
101+
<Callout type="info">
102+
**If you have a bearer token**
91103

92-
```typescript
104+
```typescript
93105
const lucid = await Lucid(
94-
new Koios(
95-
"<koios-api-url>",
96-
"<koios-bearer-token>"
97-
),
106+
new Koios("<koios-api-url>", "<koios-bearer-token>"),
98107
"Preprod"
99108
);
100-
```
109+
```
101110

102-
---
111+
</Callout>
112+
113+
</Tabs.Tab>
103114

104-
### YACI DevKit
115+
<Tabs.Tab>
105116

106117
YACI DevKit provides a local development environment with configurable block times and network parameters. For detailed setup instructions, visit the [YACI DevKit documentation](https://devkit.yaci.xyz/tutorials/lucid-evolution/overview).
118+
107119
```typescript
108120
// Configure custom network slot settings for YACI DevKit
109-
SLOT_CONFIG_NETWORK['Custom'] = {
121+
SLOT_CONFIG_NETWORK["Custom"] = {
110122
zeroTime: 1664060800000, // Unix timestamp in milliseconds
111123
zeroSlot: 0,
112124
slotLength: 1000,
113125
};
114126

115127
const lucid = await Lucid(
116-
new Kupmios(
117-
"http://localhost:1442",
118-
"http://localhost:1337"
119-
),
128+
new Kupmios("http://localhost:1442", "http://localhost:1337"),
120129
"Custom" // Use custom network type for DevKit
121130
);
122131
```
123132

124-
---
125-
126-
### UTxORPC
127-
```typescript
128-
//TODO: https://github.com/utxorpc/lucid-evolution-provider
129-
```
130-
131-
## Query the provider
132-
133-
By querying the provider you are essentially asking "what's on the blockchain?", this way you can query any on-chain data.
134-
135-
The `provider` in `lucid.provider` is the provider instance you passed to `Lucid()` when selecting your provider (Blockfrost, Kupmios, Maestro, Koios, etc.).
136-
137-
### UTxOs
138-
139-
UTxOs (Unspent Transaction Outputs) are the fundamental building blocks in Cardano's eUTxO model. One of its differentiator from account-based models is that your wallet's balance is the sum of all UTxOs at your address.
140-
141-
**Using provider**
142-
143-
```typescript
144-
const utxos = await lucid.provider.getUtxos("addr_test...");
145-
```
146-
147-
**or using convenience method**
148-
149-
```typescript
150-
const utxos = await lucid.utxosAt("addr_test...");
151-
```
152-
153-
<Callout type="info">
154-
This convenience method internally uses `lucid.provider.getUtxos()`.
155-
</Callout>
156-
157-
---
133+
</Tabs.Tab>
158134

159-
### Datums
160-
161-
In Cardano, datums are pieces of data attached to UTxOs. Lets get some terminology out of the way.
162-
163-
- *Inline datums*: When the complete datum is stored directly in the UTxO
164-
- *Datum hashes*: When only a hash of the datum is stored on-chain
165-
166-
**Using Provider**
167-
168-
```typescript
169-
const datum = await lucid.provider.getDatum("<datum_hash>");
170-
```
171-
172-
**or using convenience method**
135+
<Tabs.Tab>
173136

174137
```typescript
175-
const datum = await lucid.datumOf("<datum_hash>");
138+
https://github.com/utxorpc/lucid-evolution-provider
176139
```
177140

178-
**or querying a datum from a scriptUTxO**
179-
180-
```typescript
181-
const [scriptUtxo] = await lucid.utxosAt("addr_test...");
182-
const datum = await lucid.datumOf(scriptUtxo);
183-
```
184-
185-
<Callout type="info">
186-
`lucid.datumOf(utxo)` is a convenience method that handles both inline datums and datum hashes:
187-
188-
1. For UTxOs with inline datums → returns the datum directly
189-
2. For UTxOs with datum hashes → fetches the full datum using `provider.getDatum()`
190-
191-
Once fetched, the datum is cached in the UTxO object for subsequent queries, avoiding additional network requests.
192-
</Callout>
193-
194-
### Protocol Parameters
195-
196-
Protocol parameters define the rules and constraints of the Cardano network like tx fees, max block size, max tx size, plutus execution costs, minimum UTxO ada value
197-
198-
**Using the provider directly:**
199-
200-
```typescript
201-
const protocolParameters = await lucid.provider.getProtocolParameters();
202-
```
203-
204-
<Callout type="info">
205-
Remember that you can switch providers using the `switchProvider` method if needed.
206-
</Callout>
141+
</Tabs.Tab>
142+
143+
</Tabs>
144+
145+
## Common Queries
146+
147+
By abstracting away the provider calls, Evolution library provides different methods to query on-chain data:
148+
149+
<Tabs items={['UTxOs', 'Datums', 'Protocol Parameters']}>
150+
<Tabs.Tab>
151+
UTxOs (Unspent Transaction Outputs) are building blocks of Cardano's eUTxO model. A nuance from account-based models is that your wallet's balance is the sum of all UTxOs at your address.
152+
153+
<Tabs items={['Convenience method', 'Provider call']}>
154+
<Tabs.Tab>
155+
```typescript
156+
const utxos = await lucid.utxosAt("addr_test...");
157+
```
158+
</Tabs.Tab>
159+
<Tabs.Tab>
160+
```typescript
161+
const utxos = await lucid.provider.getUtxos("addr_test...");
162+
```
163+
</Tabs.Tab>
164+
</Tabs>
165+
166+
</Tabs.Tab>
167+
168+
<Tabs.Tab>
169+
Datums are pieces of data attached to UTxOs.
170+
171+
<Tabs items={['Convenience method', 'Provider call', 'Script UTxOs']}>
172+
<Tabs.Tab>
173+
```typescript
174+
const datum = await lucid.datumOf("<datum_hash>");
175+
```
176+
</Tabs.Tab>
177+
<Tabs.Tab>
178+
```typescript
179+
const datum = await lucid.provider.getDatum("<datum_hash>");
180+
```
181+
</Tabs.Tab>
182+
<Tabs.Tab>
183+
```typescript
184+
const [scriptUtxo] = await lucid.utxosAt("addr_test...");
185+
const datum = await lucid.datumOf(scriptUtxo);
186+
```
187+
</Tabs.Tab>
188+
</Tabs>
189+
190+
</Tabs.Tab>
191+
192+
<Tabs.Tab>
193+
Protocol parameters define the rules and constraints of the Cardano network like tx fees, max block size, max tx size, plutus execution costs, minimum UTxO ada value
194+
195+
```typescript
196+
const protocolParameters = await lucid.provider.getProtocolParameters();
197+
```
198+
199+
<Callout type="info">
200+
Remember that you can switch providers using the `switchProvider` method if needed.
201+
</Callout>
202+
203+
</Tabs.Tab>
204+
</Tabs>

0 commit comments

Comments
 (0)