About
Evolution-SDK is the next generation transaction builder for users and an off-chain framework for highly scalable dApps on Cardano. The library is designed with modularity in mind, allowing you to:
- Build and simulate transactions
- Work with different Cardano networks (Mainnet, Preprod, Preview, or Custom networks)
- Choose from multiple provider options for blockchain interaction
Quickstart
Install Dependency
Install Evolution-SDK for your project by following the installation guide.
Specify Provider
To instantiate a Lucid object, you need to specify the provider you want to use.
For example, using Blockfrost :
import { Lucid, Blockfrost } from "@evolution-sdk/lucid";
const lucid = await Lucid(
new Blockfrost(
"https://cardano-preview.blockfrost.io/api/v0",
"<blockfrost-api-key>" // obtain key from blockfrost.io
),
"Preview" // "Mainnet" | "Preprod" | "Preview" | "Custom"
);
Select Wallet
Next, you select a wallet to be used (or connected if it’s a CIP-30 wallet).
import { WalletApi } from "@evolution-sdk/lucid";
// Check if wallet is available in browser
if (window.cardano?.eternl) {
// Connect to Eternl wallet
const walletApi: WalletApi = await window.cardano.eternl.enable();
lucid.selectWallet.fromAPI(walletApi);
} else {
console.log("Eternl wallet is not installed");
}
// Alternative: check multiple wallets
const availableWallets = Object.keys(window.cardano || {});
console.log("Available wallets:", availableWallets);
Build Transaction
Let’s build a dummy transaction, it’s just sending some ADA to another address and attaching some metadata.
const tx = await lucid
.newTx()
.pay.ToAddress("addr_test1...", { lovelace: 20_000_000n }) // 20 ADA
.attachMetadata(674, {
msg: ["Hello, Evolution-SDK!"],
})
.complete();
Sign and Submit
Lastly, to submit the transaction, it must be signed.
const signedTx = await tx.sign.withWallet().complete();
const txHash = await signedTx.submit();
Putting it all Together
import { Lucid, Blockfrost, WalletAPI } from "@evolution-sdk/lucid";
async function helloLucid() {
// instantiate a Lucid object by providing Blockfrost as the provider
const lucid = await Lucid(
new Blockfrost(
"https://cardano-preview.blockfrost.io/api/v0",
"<blockfrost-api-key>", // obtain key from blockfrost.io
),
"Preview", // "Mainnet" | "Preprod" | "Preview" | "Custom"
);
// check if wallet is available and connect
if (window.cardano?.eternl) {
const walletApi = await window.cardano.eternl.enable();
lucid.selectWallet.fromAPI(walletApi);
} else {
throw new Error("Eternl wallet is not installed");
}
// contruct the transaction builder
const tx = await lucid
.newTx()
.pay.ToAddress("addr_test1...", { lovelace: 20_000_000n }) // 20 ADA
.attachMetadata(674, {
msg: ["Hello, Evolution-SDK!"]
})
.complete();
// sign and submit the transaction
const signedTx = await tx.sign.withWallet().complete();
const txHash = await signedTx.submit();
console.log({ txHash });
}
For more detailed information of building and submitting your first transaction, visit this page.
Last updated on