Mesh Wallet

Mesh Wallet provides a set of APIs to interact with the blockchain. This wallet is compatible with Mesh transaction builders.

Whether you are building a minting script, or an application that requires multi-signature, MeshWallet is all you need to get started.

Initialize wallet

This API enables applications to load and initialize a wallet connection. It provides access to the wallet's capabilities, such as signing transactions, submitting transactions, and querying blockchain data.

The wallet connection is established securely, ensuring that sensitive operations are handled by the wallet and not exposed to the application directly. This is crucial for maintaining security and user trust.

Applications can use this functionality to integrate wallet features seamlessly, enabling blockchain interactions without requiring users to manage private keys manually.

You can initialize Mesh Wallet with:

  • mnemonic phrases
  • private keys
  • Cardano CLI generated keys
  • address (read only wallet)

First, we initialize a Provider, which we will assign provider to the fetcher and submitter.

Mnemonic phrases

We can load wallet with mnemonic phrases:

With the wallet loaded, you can sign transactions, we will see how to do this in the next section, for now lets get the wallet's address:

Private keys

We can load wallet with private keys:

Cardano CLI generated skeys

We can load wallet with CLI generated keys by providing the skey generated by Cardano CLI. There are two files generated by Cardano CLI, by default it is named signing.skey and stake.skey. Opening the signing.skey file it should contains:

We can get the cborHex from the signing.skey file, and load wallet with Cardano CLI generated skeys. Stake key is optional, but without it, you cannot sign staking transactions.

Address

We can load wallet with address, this is useful for read-only wallets. A read-only wallet can only query the blockchain, it cannot sign transactions. This is useful for monitoring wallets. We can load wallet with the address type:

Initialize wallet

After creating the wallet, we need to initialize it. This will initialize the cryptography library.

With the wallet loaded, you can sign transactions, we will see how to do this in the next section, for now lets get the wallet's address:

Load wallet with mnemonic phrases

Provide the mnemonic phrases to recover your wallet. After initializing the MeshWallet, we will get the wallet's payment address.

Note: Trying these demo with your Testnet wallet is recommended.

Generate Wallet

You can generate deterministic keys based on the Bitcoin BIP39. These mnemonic phrases are essential for recovering your wallet and ensuring secure access to your funds.

Once you have your mnemonic phrase, you can use it to generate deterministic keys. These keys include a series of private and public keys, which are crucial for managing your cryptocurrencies securely.

Alternatively, you can generate private keys directly by passing `true` to the `brew` function. This approach is useful for scenarios where you need immediate access to private keys without mnemonic phrases.

Generate mnemonic

Generate new mnemonic phrases for your wallet

Generate private key

Generate new private key for your wallet

Get Balance

This API returns a comprehensive list of all assets in the wallet, including lovelace. Each asset is represented as an object with the following properties:

  • unit: A unique identifier for the asset, often used for display purposes.
  • quantity: The amount of the asset held in the wallet.

Example response:

Get Balance

Get all assets in the connected wallet

Get Change Address

This API returns an address owned by the wallet that should be used as a change address. A change address is essential during transaction creation to ensure leftover assets are securely returned to the connected wallet.

The change address helps maintain the integrity of transactions by preventing asset loss and ensuring proper allocation of funds.

Get Change Address

Get address that should be used for transaction's change

Get Collateral

This API retrieves a list of UTXOs (unspent transaction outputs) controlled by the wallet that are suitable for use as collateral inputs in transactions involving Plutus script inputs. Collateral UTXOs are pure ADA-only UTXOs required to meet the specified ADA value target.

If the target cannot be met, an error message explaining the issue will be returned. Wallets may return UTXOs exceeding the target value but must never return UTXOs below the specified value.

Example response:

This API accepts the addressType parameter, where you can specify the type of address you want to get. The available options are:

  • payment (default)
  • enterprise
Get Collateral

Get list of UTXOs that used as collateral inputs for transactions with plutus script inputs

Get Network ID

This API returns the network ID of the currently connected account. The network ID indicates the environment in which the wallet is operating:

  • 0: Testnet
  • 1: Mainnet

Other network IDs may be returned by wallets, but these are not governed by CIP-30. The network ID remains consistent unless the connected account changes.

Get Network ID

Get currently connected network

Get Reward Addresses

This API retrieves a list of reward addresses owned by the wallet. Reward addresses are stake addresses used to receive rewards from staking activities.

Reward addresses typically start with the `stake` prefix, making them easily identifiable. These addresses are essential for tracking staking rewards and managing staking operations.

Example response:

Get Reward Addresses

Get stake addresses

Get Unused Addresses

This API retrieves a list of unused addresses controlled by the wallet. Unused addresses are wallet-controlled addresses that have not been involved in any transactions.

Unused addresses are important for maintaining privacy and security in transactions. They can be used for new transactions without revealing previous activity.

Example response:

Get Unused Addresses

Get addresses that are unused

Get Used Addresses

This API retrieves a list of used addresses controlled by the wallet. Used addresses are wallet-controlled addresses that have been involved in transactions.

Tracking used addresses is essential for analyzing transaction history and managing wallet activity. These addresses provide insights into past transactions.

Example response:

Get Used Addresses

Get addresses that are used

Get UTXOs

This API retrieves a list of all UTXOs (unspent transaction outputs) controlled by the wallet. UTXOs are essential for constructing transactions and managing wallet balances.

Each UTXO includes details such as the transaction hash, output index, address, and amount. These details are crucial for identifying and utilizing unspent outputs.

Example response:

This API accepts the addressType parameter, where you can specify the type of address you want to get. The available options are:

  • payment (default)
  • enterprise
Get UTXOs

Get UTXOs of the connected wallet

Sign Data

This API allows applications to request the signing of arbitrary data using the private keys managed by the connected wallet. This is useful for verifying the authenticity of data or creating cryptographic proofs.

The wallet ensures that the signing process is secure and that private keys are not exposed during the operation. The signed data can be used for various purposes, such as authentication, data integrity checks, or blockchain interactions.

This functionality is essential for applications that require secure and verifiable data signing capabilities.

Example of a response from the endpoint:

Continue reading this guide to learn how to verify the signature.

Sign data

Define a payload and sign it with wallet.

Sign Transaction

This API enables applications to request the signing of a transaction using the private keys managed by the connected wallet. Signing a transaction is a critical step in ensuring its authenticity and authorization.

The wallet ensures that the transaction is signed securely, preventing unauthorized access to private keys. Once signed, the transaction can be submitted to the blockchain network for processing.

This functionality is vital for applications that need to interact with the blockchain securely, as it delegates sensitive operations to the wallet.

Sign Transaction

Create a transaction and sign it

Check out Transaction to learn more on how to use this API.

Submit Transaction

This API allows applications to request the submission of a signed transaction through the connected wallet. The wallet will attempt to send the transaction to the blockchain network.

If the transaction is successfully submitted, the wallet returns the transaction ID, which can be used by the application to track its status on the blockchain. In case of an error during submission, the wallet provides error messages or failure details.

This functionality is essential for applications that rely on wallet integration to handle transaction submission securely and efficiently.

Submit Transaction

Submit a signed transaction with wallet

Check out Transaction to learn more on how to use this API.

Create Collateral UTXO

Collateral is a monetary guarantee provided by the user to ensure the integrity of smart contracts and compensate nodes in case phase-2 validation fails. It is specified during transaction construction by adding collateral inputs to the transaction.

The total balance in the UTXOs corresponding to these inputs represents the transaction's collateral amount. If the contract executes successfully, the collateral remains safe. This mechanism ensures that contracts are carefully designed and thoroughly tested.

Example:

Get Assets

This API retrieves a list of assets in the wallet, excluding lovelace. Each asset is represented as an object with the following properties:

  • unit: A unique identifier for the asset.
  • policyId: The policy ID associated with the asset.
  • assetName: The name of the asset.
  • fingerprint: A unique fingerprint for the asset.
  • quantity: The amount of the asset held in the wallet.

Example response:

Get Assets

Get assets in the connected wallet

Get Lovelace

This API retrieves the lovelace balance in the wallet. Lovelace is the smallest unit of ADA, where 1 ADA equals 1,000,000 lovelace.

Knowing the lovelace balance is essential for managing wallet funds and performing transactions.

Get Lovelace

Get amount of ADA in connected wallet

Get Policy IDs

This API retrieves a list of policy IDs from all assets in the wallet. A policy ID is a unique identifier that groups assets under a common policy.

Policy IDs are useful for querying assets associated with specific policies. For example, you can use a policy ID to retrieve all assets belonging to that policy.

Example response:

Get Policy IDs

Get a list of policy IDs from all assets in wallet

Get a Collection of Assets

This API retrieves a list of assets associated with a specific policy ID. A policy ID is a unique identifier that groups assets under a common policy.

If no assets in the wallet belong to the specified policy ID, an empty list is returned. To query for available policy IDs, use wallet.getPolicyIds().

Get a Collection of Assets

Get a list of assets belonging to the policy ID

Get DRep

The DRep ID is a unique identifier for the user's wallet. It consists of three components:

  • publicKey: The public key associated with the wallet.
  • publicKeyHash: A hash of the public key for verification purposes.
  • dRepIDCip105: The bech32 encoding of the DRep ID.

Example response:

Get DRep ID Key

Get the key, hash, and bech32 address of the DRep ID