Api

Asset API

Asset registry and token management

The Asset API provides access to the asset registry and token management functionality.

Endpoints


Get Assets

Get all registered assets for a specific network.

Service: AssetServiceMethod: GetAssets

Parameters:

NameTypeRequiredDescription
networkNetworkYESNetwork to query assets for

Response:

FieldTypeDescription
assetsAsset[]Array of registered assets

Asset Object:

FieldTypeDescription
idstringAsset identifier
namestringAsset name
symbolstringAsset symbol
decimalsuint32Number of decimal places
is_nativeboolWhether this is the network's native asset

Example Request:

TypeScript
const assets = await hydraGrpcClient.getAssets({
  protocol: Protocol.EVM,
  id: '11155111' // Ethereum Sepolia
})
Rust
let request = tonic::Request::new(GetAssetsRequest {
    network: Some(Network {
        protocol: Protocol::Evm as i32,
        id: "11155111".to_string(),
    }),
});

let response = client.get_assets(request).await?;
let assets = response.into_inner().assets;

Get Asset

Get information about a specific asset.

Service: AssetServiceMethod: GetAsset

Parameters:

NameTypeRequiredDescription
networkNetworkYESNetwork the asset is on
asset_idstringYESAsset identifier

Response:

FieldTypeDescription
assetAssetAsset details

Example Request:

TypeScript
const asset = await hydraGrpcClient.getAsset({
  network: {
    protocol: Protocol.EVM,
    id: '11155111'
  },
  assetId: '0x...' // USDC contract address
})
Rust
let request = tonic::Request::new(GetAssetRequest {
    network: Some(Network {
        protocol: Protocol::Evm as i32,
        id: "11155111".to_string(),
    }),
    asset_id: "0x...".to_string(),
});

let response = client.get_asset(request).await?;
let asset = response.into_inner().asset;

Get Native Asset

Get the native asset for a network (e.g., BTC for Bitcoin, ETH for Ethereum).

Service: AssetServiceMethod: GetNativeAsset

Parameters:

NameTypeRequiredDescription
networkNetworkYESNetwork to get native asset for

Response:

FieldTypeDescription
assetAssetNative asset details

Example Request:

TypeScript
const nativeAsset = await hydraGrpcClient.getNativeAsset({
  protocol: Protocol.BITCOIN,
  id: '0a03cf40' // Bitcoin Signet
})
// Returns BTC asset info
Rust
let request = tonic::Request::new(GetNativeAssetRequest {
    network: Some(Network {
        protocol: Protocol::Bitcoin as i32,
        id: "0a03cf40".to_string(),
    }),
});

let response = client.get_native_asset(request).await?;
let asset = response.into_inner().asset;

Add Token

Register a new token to the asset registry.

Service: AssetServiceMethod: AddToken

Parameters:

NameTypeRequiredDescription
networkNetworkYESNetwork the token is on
token_addressstringYESToken contract address (EVM) or asset ID

Response:

FieldTypeDescription
assetAssetAdded asset details

Example Request:

TypeScript
// Add USDC token on Ethereum Sepolia
const asset = await hydraGrpcClient.addToken({
  network: {
    protocol: Protocol.EVM,
    id: '11155111'
  },
  tokenAddress: '0x...' // USDC contract address
})
Rust
let request = tonic::Request::new(AddTokenRequest {
    network: Some(Network {
        protocol: Protocol::Evm as i32,
        id: "11155111".to_string(),
    }),
    token_address: "0x...".to_string(),
});

let response = client.add_token(request).await?;
let asset = response.into_inner().asset;

Common Patterns

Get all assets including native

Rust
async fn get_all_network_assets(
    client: &mut AssetServiceClient<Channel>,
    network: Network,
) -> Result<Vec<Asset>, Box<dyn std::error::Error>> {
    let response = client
        .get_assets(GetAssetsRequest {
            network: Some(network),
        })
        .await?;

    Ok(response.into_inner().assets)
}

Error Handling

Error CodeDescriptionSolution
INVALID_ARGUMENTInvalid network or asset IDVerify parameters
NOT_FOUNDAsset not foundCheck asset exists on this network
ALREADY_EXISTSToken already registeredUse GetAsset instead

Best Practices

  1. Cache asset info - Asset details don't change frequently
  2. Verify token contracts - Always verify token addresses before adding
  3. Check decimals - Different tokens have different decimal places
  4. Native asset first - Get native asset info for proper fee calculation

← Back to API Reference | Next: Blockchain API →


Copyright © 2025