Types
TypeScript type definitions for the Iagon Insight API.
Response Wrapper
typescript
interface IApiResponse<T> {
success: true;
data: T;
}
interface IApiError {
success: false;
error: string;
}UTXOs
typescript
interface IUtxo {
transaction_id: string;
output_index: number;
address: string;
value: IUtxoValue;
datum_hash: string | null;
datum_type: string | null;
script_hash: string | null;
created_at: ISlotReference;
}
interface IUtxoValue {
lovelace: number;
assets?: Record<string, number>;
}
interface ISlotReference {
slot_no: number;
header_hash: string;
}Usage:
typescript
type IGetUtxosResponse = IApiResponse<IUtxo[]>;Transactions
typescript
interface ITransactionSubmitRequest {
tx: string;
skipValidation?: boolean;
}
interface ITransactionSubmitData {
txHash: string;
}
interface ITransaction {
tx_hash: string;
block_hash: string;
slot_no: number;
block_no: number;
block_time: string;
fee: number;
size: number;
inputs: ITransactionInput[];
outputs: ITransactionOutput[];
}
interface ITransactionInput {
tx_hash: string;
output_index: number;
address: string;
value: IUtxoValue;
}
interface ITransactionOutput {
output_index: number;
address: string;
value: IUtxoValue;
}
interface ITransactionSummary {
tx_hash: string;
block_hash: string;
slot_no: number;
block_no: number;
block_time: string;
}
interface IPagination {
limit: number;
offset: number;
total: number;
hasMore: boolean;
next_cursor?: number;
}
interface ILastUpdated {
slot_no: number;
block_hash: string;
block_time: string;
}
interface IPaginatedResponse<T> {
success: true;
data: T[];
pagination: IPagination;
last_updated: ILastUpdated;
}Usage:
typescript
type ITransactionSubmitResponse = IApiResponse<ITransactionSubmitData>;
type ITransactionResponse = IApiResponse<ITransaction>;
type ITransactionsResponse = IPaginatedResponse<ITransaction>;
type ITransactionHistoryResponse = IPaginatedResponse<ITransactionSummary>;Accounts (Staking)
typescript
interface IAccountInfo {
stake_address: string;
active: boolean;
active_epoch: number | null;
active_stake: string;
rewards_sum: string;
withdrawn_rewards: string;
available_rewards: string;
pool_id: string | null;
drep_id: string | null;
}
interface IAccountReward {
epoch: number;
amount: string;
pool_id: string;
reward_type: "leader" | "member" | "reserves" | "treasury" | "refund";
}
interface IAccountDelegation {
active_epoch: number;
pool_id: string;
tx_hash: string;
cert_index: number;
}
interface IAccountWithdrawal {
tx_hash: string;
amount: string;
block_time: string;
}
interface IAccountAddress {
address: string;
}
interface IAccountAsset {
unit: string;
quantity: string;
}
interface IAccountRegistration {
tx_hash: string;
action: "registered" | "deregistered";
epoch: number;
}Usage:
typescript
type IAccountInfoResponse = IApiResponse<IAccountInfo>;
type IAccountRewardsResponse = IPaginatedResponse<IAccountReward>;
type IAccountDelegationsResponse = IPaginatedResponse<IAccountDelegation>;
type IAccountWithdrawalsResponse = IPaginatedResponse<IAccountWithdrawal>;
type IAccountAddressesResponse = IPaginatedResponse<IAccountAddress>;
type IAccountAssetsResponse = IApiResponse<IAccountAsset[]>;
type IAccountRegistrationsResponse = IPaginatedResponse<IAccountRegistration>;Health
typescript
interface IHealthData {
status: "healthy";
timestamp: string;
}Usage:
typescript
type IHealthResponse = IApiResponse<IHealthData>;Full Type Definitions
Copy this file to use in your project:
typescript
// Response types
interface IApiResponse<T> {
success: true;
data: T;
}
interface IApiError {
success: false;
error: string;
}
// UTXO types
interface IUtxo {
transaction_id: string;
output_index: number;
address: string;
value: IUtxoValue;
datum_hash: string | null;
datum_type: string | null;
script_hash: string | null;
created_at: ISlotReference;
}
interface IUtxoValue {
lovelace: number;
assets?: Record<string, number>;
}
interface ISlotReference {
slot_no: number;
header_hash: string;
}
// Transaction types
interface ITransactionSubmitRequest {
tx: string;
skipValidation?: boolean;
}
interface ITransactionSubmitData {
txHash: string;
}
interface ITransaction {
tx_hash: string;
block_hash: string;
slot_no: number;
block_no: number;
block_time: string;
fee: number;
size: number;
inputs: ITransactionInput[];
outputs: ITransactionOutput[];
}
interface ITransactionInput {
tx_hash: string;
output_index: number;
address: string;
value: IUtxoValue;
}
interface ITransactionOutput {
output_index: number;
address: string;
value: IUtxoValue;
}
interface ITransactionSummary {
tx_hash: string;
block_hash: string;
slot_no: number;
block_no: number;
block_time: string;
}
interface IPagination {
limit: number;
offset: number;
total: number;
hasMore: boolean;
next_cursor?: number;
}
interface ILastUpdated {
slot_no: number;
block_hash: string;
block_time: string;
}
interface IPaginatedResponse<T> {
success: true;
data: T[];
pagination: IPagination;
last_updated: ILastUpdated;
}
// Account types
interface IAccountInfo {
stake_address: string;
active: boolean;
active_epoch: number | null;
active_stake: string;
rewards_sum: string;
withdrawn_rewards: string;
available_rewards: string;
pool_id: string | null;
drep_id: string | null;
}
interface IAccountReward {
epoch: number;
amount: string;
pool_id: string;
reward_type: "leader" | "member" | "reserves" | "treasury" | "refund";
}
interface IAccountDelegation {
active_epoch: number;
pool_id: string;
tx_hash: string;
cert_index: number;
}
interface IAccountWithdrawal {
tx_hash: string;
amount: string;
block_time: string;
}
interface IAccountAddress {
address: string;
}
interface IAccountAsset {
unit: string;
quantity: string;
}
interface IAccountRegistration {
tx_hash: string;
action: "registered" | "deregistered";
epoch: number;
}
// Health types
interface IHealthData {
status: "healthy";
timestamp: string;
}
// Response type aliases
type IGetUtxosResponse = IApiResponse<IUtxo[]>;
type ITransactionSubmitResponse = IApiResponse<ITransactionSubmitData>;
type ITransactionResponse = IApiResponse<ITransaction>;
type ITransactionsResponse = IPaginatedResponse<ITransaction>;
type ITransactionHistoryResponse = IPaginatedResponse<ITransactionSummary>;
type IAccountInfoResponse = IApiResponse<IAccountInfo>;
type IAccountRewardsResponse = IPaginatedResponse<IAccountReward>;
type IAccountDelegationsResponse = IPaginatedResponse<IAccountDelegation>;
type IAccountWithdrawalsResponse = IPaginatedResponse<IAccountWithdrawal>;
type IAccountAddressesResponse = IPaginatedResponse<IAccountAddress>;
type IAccountAssetsResponse = IApiResponse<IAccountAsset[]>;
type IAccountRegistrationsResponse = IPaginatedResponse<IAccountRegistration>;
type IHealthResponse = IApiResponse<IHealthData>;