@minswap/internal-sdk
v0.1.8
Published
Cardano transaction-building toolkit used internally at Minswap. Wraps the Minswap and Emurgo `cardano-serialization-lib` builds plus a custom UPLC helper into a higher-level TypeScript API for constructing, evaluating, signing, and submitting transaction
Keywords
Readme
@minswap/internal-sdk
Cardano transaction-building toolkit used internally at Minswap. Wraps the Minswap and Emurgo cardano-serialization-lib builds plus a custom UPLC helper into a higher-level TypeScript API for constructing, evaluating, signing, and submitting transactions.
Install
pnpm add @minswap/internal-sdk
# or: npm install @minswap/internal-sdk
# or: yarn add @minswap/internal-sdkUsage
import {
Address,
ADA,
CoinSelectionAlgorithm,
EmulatorProvider,
NetworkEnvironment,
RustModule,
TxBuilderV2,
TxOut,
Value,
} from "@minswap/internal-sdk";
// Load WASM modules once at startup.
await RustModule.load();
const networkEnv = NetworkEnvironment.TESTNET_PREPROD;
const provider = new EmulatorProvider(networkEnv); // or your own ITxBuilderProvider
const changeAddress = Address.fromBech32("addr_test1...");
const txBuilder = new TxBuilderV2(networkEnv)
.payTo(new TxOut(changeAddress, new Value().add(ADA, 5_000_000n)));
const result = await txBuilder.complete({
changeAddress,
coinSelectionAlgorithm: CoinSelectionAlgorithm.MINSWAP,
walletUtxos,
provider,
});
if (result.type === "err") throw result.error;
const txHex = result.value.signWithPrivateKey(privateKey).complete();RustModule.load() dynamically imports the right CSL / ECSL / UPLC bindings for your runtime (Node vs. browser) and must complete before any other SDK call.
