Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/nexus/avail-nexus-sdk/_meta.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
"nexus-core": "Nexus (Headless)",
"nexus-core": "Nexus Core",
"nexus-widgets": "Nexus Widgets"
}
13 changes: 7 additions & 6 deletions app/nexus/avail-nexus-sdk/nexus-core/api-reference/page.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: 'Avail Nexus headless SDK API Reference'
description: 'Complete API reference for the Avail Nexus headless SDK including initialization, network configuration, bridging, transfers, and utility functions'
title: 'Nexus Core SDK API Reference'
description: 'Complete API reference for the Nexus Core SDK including initialization, network configuration, bridging, transfers, and utility functions'
image: '/img/docs-link-preview.png'
---

import { Callout, Steps, Tabs } from 'nextra/components'

# Avail Nexus (Headless) SDK API Reference
# Nexus Core SDK API Reference

The Avail Nexus headlessSDK provides a comprehensive set of APIs for cross-chain bridging, token transfers, and balance management across multiple EVM chains.
The Nexus Core SDK provides a comprehensive set of APIs for cross-chain bridging, token transfers, and balance management across multiple EVM chains.

## Quick Start

Expand All @@ -20,7 +20,7 @@ const sdk = new NexusSDK({ network: 'mainnet' });
await sdk.initialize(provider); // Your wallet provider

// Get unified balances
const balances = await sdk.getUnifiedBalances();
const balances = await sdk.getUnifiedBalances( true );
console.log('All balances:', balances);

// Bridge tokens
Expand Down Expand Up @@ -248,9 +248,10 @@ All events include the same `typeID` structure and runtime `data` such as `trans
import type { UserAsset, TokenBalance } from '@avail-project/nexus-core';

// Get all balances across chains
const balances: UserAsset[] = await sdk.getUnifiedBalances();
const balances: UserAsset[] = await sdk.getUnifiedBalances( true );

// Get balance for specific token
// You can optionally include swappable assets as well
const usdcBalance: UserAsset | undefined = await sdk.getUnifiedBalance('USDC');
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ Use these functions to fetch consolidated token balances across all supported ch
## Method signatures

```typescript showLineNumbers filename="Typescript"
async getUnifiedBalances(): Promise<UserAsset[]>
async getUnifiedBalance(symbol: string): Promise<UserAsset | undefined>
async getUnifiedBalances(includeSwappableBalances: boolean): Promise<UserAsset[]>
async getUnifiedBalance(symbol: string, includeSwappableBalances: boolean): Promise<UserAsset | undefined>
```

## Parameters

- `symbol` (string, required for `getUnifiedBalance`): Token symbol, e.g. `'USDC' | 'USDT' | 'ETH'`.
- `includeSwappableBalances` (boolean, optional; default `false`):
- `false` (default): Only return CA-supported assets (tokens that can be used directly in chain abstraction flows).
- `true`: Also include swappable wallet assets that the SDK can utilize via swap as sources for operations. This includes tokens that are not CA-supported but can be used via swap.


### `getUnifiedBalances()`

Expand All @@ -39,16 +43,31 @@ Fetches the unified balance of all tokens across all chains for a user.
await sdk.getUnifiedBalances(): Promise<UserAsset[]>
```

### `getUnifiedBalance(symbol)`
### `getUnifiedBalance()`

Fetches the unified balance of all tokens across all chains for a user.

```typescript showLineNumbers filename="Typescript"
// Default: CA-supported assets only
const balances = await sdk.getUnifiedBalances();

// Include swappable assets as well
const balancesWithSwappable = await sdk.getUnifiedBalances(true);
```

### `getUnifiedBalance()`

Fetches the unified balance of a specific token across all chains for a user.

```typescript showLineNumbers filename="Typescript"
// Takes a token symbol parameter
await sdk.getUnifiedBalance(symbol: string): Promise<UserAsset | undefined>
// Default: CA-supported assets only
const usdc = await sdk.getUnifiedBalance('USDC');

// Include swappable assets as well in search
const usdcFromAllSources = await sdk.getUnifiedBalance('USDC', true);
```

## Example
## Example

Here are some minimal examples of how to use the functions to fetch the unified balance of a user:

Expand All @@ -58,14 +77,14 @@ const allBalances = await sdk.getUnifiedBalances();
console.log('All balances:', allBalances);

// Get balance for specific token
const usdcBalance = await sdk.getUnifiedBalance('USDC');
const usdcBalance = await sdk.getUnifiedBalance('USDC', true);
console.log('USDC balance:', usdcBalance);
```

## Return Value

- `getUnifiedBalances()`: Returns `Promise<UserAsset[]>` - Array of `UserAsset` class instances
- `getUnifiedBalance(symbol)`: Returns `Promise<UserAsset | undefined>` - Single `UserAsset` instance or undefined
- `getUnifiedBalances(includeSwappableBalances)`: Returns `Promise<UserAsset[]>` - Array of `UserAsset` class instances
- `getUnifiedBalance(symbol, includeSwappableBalances)`: Returns `Promise<UserAsset | undefined>` - Single `UserAsset` instance or undefined

```typescript showLineNumbers filename="Typescript"
class UserAsset {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Avail Nexus SDK provides a comprehensive set of APIs for cross-chain bridgin
<Callout type="info">
**Note:** <br/>
This page will focus on the UI widgets available as part of the Avail Nexus SDK.
If you are looking for the API reference for the headless SDK, please refer to [this](/nexus/avail-nexus-sdk/examples/nexus-core/api-reference) page.
If you are looking for the API reference for the Nexus Core SDK, please refer to [this](/nexus/avail-nexus-sdk/examples/nexus-core/api-reference) page.
</Callout>

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion app/nexus/introduction-to-nexus/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ Developers benefit from the '*deploy once, scale everywhere*' paradigm that Nexu
Test out our app demos with Nexus embedded, to see how you can also tap into cross-chain liquidity in seconds.

- [Nexus UI Demo](https://nexus-demo.availproject.org/)
- [Nexus Headless SDK Demo](https://avail-headless-nexus-demo.avail.so/)
- [Nexus Core SDK Demo](https://avail-headless-nexus-demo.avail.so/)
- [Hyperliquid Demo](https://avail-project.notion.site/Avail-Nexus-x-HyperLiquid-257e67c666dd80cc9589e661b2460fbb)
2 changes: 1 addition & 1 deletion app/nexus/nexus-cheatsheet/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The headless version , for fine-grained control over the Nexus SDK.
We also built a demo app with `nexus-core` to provide more reference code:

<Cards num={2}>
<Cards.Card title="Nexus Headless Demo" icon={<LinkIcon />} href="https://avail-nexus-demo-five.vercel.app/" target="_blank" rel="noopener noreferrer" arrow />
<Cards.Card title="Nexus Core Demo" icon={<LinkIcon />} href="https://avail-nexus-demo-five.vercel.app/" target="_blank" rel="noopener noreferrer" arrow />
<Cards.Card title="Github Link" icon={<GithubIcon24 className="svg-inherit" />} href="https://github.com/availproject/avail-nexus-demo" target="_blank" rel="noopener noreferrer" arrow />
</Cards>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ by using an injected wallet provider that follows the [`EIP-1193`](https://eips.
- And to do that, you need to call the `.initialize()` function of the SDK while passing
the wallet provider to it.

- The flows to do this differ between the headless and the widgets SDK.
- The flows to do this differ between Nexus Core and Nexus Widgets.
We will go over both of them in this tutorial.

<Callout>
Expand Down
2 changes: 1 addition & 1 deletion app/nexus/nexus-overview/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pnpm add @avail-project/nexus-core

<Callout type="info">

1. The headless SDK still requires an injected wallet provider (e.g. MetaMask, WalletConnect, etc.)
1. Nexus Core SDK still requires an injected wallet provider (e.g. MetaMask, WalletConnect, etc.)
2. It is designed for client-side browser environments and **cannot be used** in any server-side environments.
</Callout>

Expand Down
4 changes: 2 additions & 2 deletions app/nexus/nexus-quickstart/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ This page will help you get started with `nexus-core` as well as `nexus-widgets`
## Nexus Core

<Callout type="info">
We also made a demo app for the headless package to make it easier for devs to get on-boarded with the Avail Nexus SDK:
We also made a demo app for Nexus Core to make it easier for devs to get on-boarded with the Avail Nexus SDK:

- [avail-headless-nexus-demo.avail.so](https://avail-headless-nexus-demo.avail.so/)
- [Github repo for the demo app](https://github.com/availproject/avail-nexus-demo)
</Callout>

Getting started with the headless Nexus SDK is simple.
Getting started with Nexus core is simple.

<Steps>

Expand Down