Interface Cip30Wallet

Represents a CIP-30 compatible Cardano wallet for dApp interaction.

interface Cip30Wallet {
    cip142: { getNetworkMagic: () => Promise<number> };
    cip95: {
        getPubDRepKey: () => Promise<string>;
        getRegisteredPubStakeKeys: () => Promise<string[]>;
        getUnregisteredPubStakeKeys: () => Promise<string[]>;
    };
    getBalance(): Promise<string>;
    getChangeAddress(): Promise<string>;
    getCollateral(): Promise<string[]>;
    getNetworkId(): Promise<number>;
    getRewardAddresses(): Promise<string[]>;
    getUnusedAddresses(): Promise<string[]>;
    getUsedAddresses(): Promise<string[]>;
    getUtxos(): Promise<undefined | string[]>;
    signData(
        address: string,
        payload: string,
    ): Promise<{ key: string; signature: string }>;
    signTx(tx: string, partialSign: boolean): Promise<string>;
    submitTx(tx: string): Promise<string>;
}

Properties

cip142: { getNetworkMagic: () => Promise<number> }

Namespace for CIP-142 methods.

Type declaration

  • getNetworkMagic: () => Promise<number>

    Returns the "network magic," a unique number identifying the Cardano network.

cip95: {
    getPubDRepKey: () => Promise<string>;
    getRegisteredPubStakeKeys: () => Promise<string[]>;
    getUnregisteredPubStakeKeys: () => Promise<string[]>;
}

Namespace for CIP-95 governance methods, supporting the Voltaire era.

Type declaration

  • getPubDRepKey: () => Promise<string>

    Returns the wallet's active public DRep (Delegated Representative) key.

  • getRegisteredPubStakeKeys: () => Promise<string[]>

    Returns public stake keys from the wallet that are currently registered for on-chain governance voting.

  • getUnregisteredPubStakeKeys: () => Promise<string[]>

    Returns public stake keys from the wallet that are NOT yet registered for on-chain governance voting.

Methods

  • Returns the total balance of all assets controlled by the wallet.

    Returns Promise<string>

    A promise that resolves to the wallet's total balance, including Lovelace and any native tokens.

  • Returns a single, unused address suitable for receiving change from a transaction.

    Returns Promise<string>

    A promise that resolves to a Bech32-encoded change address.

  • Returns a list of UTXOs that are designated as collateral.

    Returns Promise<string[]>

    A promise that resolves to an array of collateral UTXOs.

    Collateral is required for transactions that interact with Plutus smart contracts to cover potential script execution failure fees.

  • Returns the wallet's current network ID.

    Returns Promise<number>

    A promise that resolves to the network ID (0 for Testnet, 1 for Mainnet).

    This is used to ensure the dApp and wallet are operating on the same network.

  • Returns the wallet's reward addresses, used for receiving staking rewards.

    Returns Promise<string[]>

    A promise that resolves to an array of Bech32-encoded reward addresses.

  • Returns a list of unused addresses for receiving payments.

    Returns Promise<string[]>

    A promise that resolves to an array of unused, Bech32-encoded addresses.

    Using a fresh address for each transaction can improve user privacy.

  • Returns a list of addresses that have been used in past transactions.

    Returns Promise<string[]>

    A promise that resolves to an array of used, Bech32-encoded addresses.

  • Returns a list of all Unspent Transaction Outputs (UTXOs) controlled by the wallet.

    Returns Promise<undefined | string[]>

    A promise that resolves to an array of UTXOs.

    UTXOs represent the "coins" or assets in the wallet that are available to be spent.

  • Requests the user to sign arbitrary data with a specific address, compliant with CIP-8.

    Parameters

    • address: string

      The Bech32-encoded address to sign with.

    • payload: string

      The hex-encoded data payload to be signed.

    Returns Promise<{ key: string; signature: string }>

    A promise that resolves to the signature and public key.

    This is useful for proving ownership of an address without creating a blockchain transaction.

  • Requests the user to sign a given transaction.

    Parameters

    • tx: string

      The transaction to be signed, provided as a CBOR hex string.

    • partialSign: boolean

      If true, the wallet will only add its witness and not require all signatures to be present. This is for multi-signature transactions.

    Returns Promise<string>

    A promise that resolves to the CBOR hex string of the transaction witness set.

  • Submits a fully signed transaction to the blockchain through the wallet's provider.

    Parameters

    • tx: string

      The fully signed transaction, provided as a CBOR hex string.

    Returns Promise<string>

    A promise that resolves to the transaction ID (hash).