Providers
Transaction Submission
Submit transactions and monitor confirmations
Transaction Submission
Providers handle transaction submission and confirmation monitoring. Submit pre-signed transactions and track their status on the blockchain.
Basic Submission
Submit a signed transaction CBOR string:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
// Submit signed transaction
const = "84a300..."; // Signed transaction CBOR
const = await .();
.("Transaction submitted:", );Wait for Confirmation
Monitor transaction until confirmed on blockchain:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
const = "84a300...";
const = await .();
// Wait for confirmation (checks every 5 seconds by default)
const = await .();
if () {
.("Transaction confirmed!");
} else {
.("Transaction not found");
}Custom Check Interval
Specify how often to check for confirmation:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
const = "abc123...";
// Check every 10 seconds
const = await .(, 10000);
.("Confirmed:", );Transaction Evaluation
Evaluate transaction before submission to estimate script execution costs:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
const = "84a300..."; // Unsigned transaction
// Evaluate script execution
const = await .();
.(() => {
.("Redeemer tag:", .);
.("Redeemer index:", .);
.("Memory units:", ..);
.("CPU steps:", ..);
});Submission Service Pattern
Create a transaction submission service with error handling:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
interface SubmissionResult {
: boolean;
?: string;
?: boolean;
?: string;
}
export async function (
: string,
= 5000
): <SubmissionResult> {
try {
const = await .();
.("Transaction submitted:", );
const = await .(, );
return {
: true,
,
};
} catch (: any) {
.("Submission failed:", );
return {
: false,
: .message
};
}
}Batch Submission
Submit multiple transactions sequentially:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
async function (: string[]) {
const = [];
for (const of ) {
try {
const = await .();
.("Submitted:", );
const = await .();
.({
: true,
,
});
} catch (: any) {
.({
: false,
: .message
});
}
}
return ;
}Error Handling
Handle common submission errors:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
async function (: string) {
try {
const = await .();
return { : true as , };
} catch (: any) {
// Common errors
if (.message.includes("OutsideValidityIntervalUTxO")) {
return {
: false as ,
: "Transaction expired (outside validity interval)"
};
}
if (.message.includes("BadInputsUTxO")) {
return {
: false as ,
: "UTxO already spent"
};
}
if (.message.includes("ValueNotConservedUTxO")) {
return {
: false as ,
: "Input/output value mismatch"
};
}
if (.message.includes("FeeTooSmallUTxO")) {
return {
: false as ,
: "Transaction fee too low"
};
}
return {
: false as ,
: .message
};
}
}Retry Logic
Implement retry logic for transient failures:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
async function (
: string,
= 3,
= 1000
) {
let : any;
for (let = 1; <= ; ++) {
try {
const = await .();
.(`Success on attempt ${}:`, );
return { : true as , };
} catch (: any) {
= ;
.(`Attempt ${} failed:`, .message);
// Don't retry on certain errors
if (
.message.includes("BadInputsUTxO") ||
.message.includes("OutsideValidityIntervalUTxO")
) {
break;
}
if ( < ) {
await new ( => (, ));
}
}
}
return {
: false as ,
: ?.message || "Unknown error"
};
}Monitoring Pattern
Track transaction status with periodic checks:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
async function (
: string,
= 300000, // 5 minutes
= 5000
): <boolean> {
const = .();
while (.() - < ) {
try {
const = await .(, );
if () {
.("Transaction confirmed:", );
return true;
}
} catch (: any) {
.("Monitoring error:", );
}
await new ( => (, ));
}
.("Transaction confirmation timeout:", );
return false;
}Complete Submission Flow
End-to-end transaction submission with all error handling:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
interface TransactionStatus {
: "submitted" | "confirmed" | "failed";
?: string;
?: string;
?: number;
?: Date;
}
export async function (
: string
): <TransactionStatus> {
const = 3;
let = 0;
// Submission with retry
while ( < ) {
++;
try {
const = await .();
.(`Submitted (attempt ${}):`, );
// Wait for confirmation
const = await .(, 5000);
if () {
return {
: "confirmed",
,
,
: new ()
};
}
return {
: "submitted",
,
};
} catch (: any) {
.(`Attempt ${} failed:`, .message);
// Terminal errors - don't retry
if (
.message.includes("BadInputsUTxO") ||
.message.includes("OutsideValidityIntervalUTxO") ||
.message.includes("ValueNotConservedUTxO")
) {
return {
: "failed",
: .message,
};
}
// Wait before retry
if ( < ) {
await new ( => (, 2000));
}
}
}
return {
: "failed",
: "Max retries exceeded",
};
}Evaluation Before Submission
Validate scripts before submitting:
import { } from "@evolution-sdk/evolution";
const = ({
: "mainnet",
: {
: "blockfrost",
: "https://cardano-mainnet.blockfrost.io/api/v0",
: ..!
}
});
async function (: string) {
try {
// Evaluate first
const = await .();
.("Script evaluation:");
.((, ) => {
.(` Redeemer ${}:`, {
: .,
: ..,
: ..
});
});
// Submit if evaluation succeeds
const = await .();
const = await .();
return {
: true,
,
,
};
} catch (: any) {
return {
: false,
: .message
};
}
}Next Steps
Explore real-world use cases:
- Use Cases - Complete examples and patterns
- Provider Types - Choose the right provider