Skip to content

Commit

Permalink
feat: add some lucid evolution infos about time management (#80)
Browse files Browse the repository at this point in the history
* feat: add some lucid evolution infos about time management

* fix: slotLength is in shelleyParams too
  • Loading branch information
Proxiweb authored Nov 15, 2024
1 parent 84d8276 commit 2196d47
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion docs/pages/tutorials/lucid-evolution/overview.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# Lucid evolution

https://github.com/Anastasia-Labs/lucid-evolution

//TODO
Note : To be able to add **validFrom** and **validTo** constraints to a transaction you have to give Lucid Evolution some Yaci DevKit related informations :

```typescript
import { Kupmios, Lucid, SLOT_CONFIG_NETWORK } from "@lucid-evolution/lucid";

// we fetch the local cluster info to determine the start time
const shelleyParams: any = await fetch("http://localhost:10000/local-cluster/api/admin/devnet/genesis/shelley").then(
(res) => res.json()
);

const zeroTime = new Date(shelleyParams.systemStart).getTime();
const slotLength = shelleyParams.slotLength * 1000; // in milliseconds

// for a default devkit cluster, we can now configure time parameters
SLOT_CONFIG_NETWORK["Custom"] = { zeroTime, slotLength, zeroSlot: 0 };

// for example we use a kupmios configurion
const kupmios = new Kupmios("http://localhost:1442", "http://localhost:1337");
// now we use our Kupmios provider and tell to use our Custom config settings
const lucid = await Lucid(kupmios, "Custom");

const currentTime = Date.now() - 10000;
const laterTime = currentTime + 1000000;
const tx = await lucid
.newTx()
.validFrom(currentTime)
.validTo(laterTime)
.pay.ToAddress("addr_testa...", { lovelace: 5000000n })
.pay.ToAddress("addr_testb...", { lovelace: 5000000n })
.complete();
```

0 comments on commit 2196d47

Please sign in to comment.