Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 4.1.15 - Oct 10, 2025
Changes:
- Update dependencies to latest versions

## 4.1.6-15 July 7, 2022
Changes:
- Changes homa sdk interface name subscribeEnv -> env$
Expand Down
116 changes: 87 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,107 @@
![license](https://img.shields.io/badge/License-Apache%202.0-blue?logo=apache&style=flat-square)
[![npm](https://img.shields.io/npm/v/@acala-network/api?logo=npm&style=flat-square)](https://www.npmjs.com/package/@acala-network/api)
# 🌊 Acala.js

# @acala-network
[![License](https://img.shields.io/badge/License-Apache%202.0-blue?logo=apache&style=flat-square)](https://github.com/AcalaNetwork/acala.js/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/@acala-network/sdk?logo=npm&style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk)
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square)](https://www.typescriptlang.org/)
[![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22-green?logo=node.js&style=flat-square)](https://nodejs.org/)

This library provides additional typing information for user to access Acala Network by using [polkadot.js](https://github.com/polkadot-js/api).

# Getting Started
## 📦 Packages

More documentation and examples on [wiki](https://github.com/AcalaNetwork/acala.js/wiki).
| Package | Description | Version |
|---------|-------------|---------|
| [`@acala-network/sdk`](./packages/sdk) | Main SDK with wallet, DeFi protocols | [![npm](https://img.shields.io/npm/v/@acala-network/sdk?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk) |
| [`@acala-network/sdk-core`](./packages/sdk-core) | Core utilities, tokens, math operations | [![npm](https://img.shields.io/npm/v/@acala-network/sdk-core?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk-core) |
| [`@acala-network/sdk-swap`](./packages/sdk-swap) | DEX trading and liquidity operations | [![npm](https://img.shields.io/npm/v/@acala-network/sdk-swap?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk-swap) |
| [`@acala-network/sdk-loan`](./packages/sdk-loan) | CDP (Collateralized Debt Position) management | [![npm](https://img.shields.io/npm/v/@acala-network/sdk-loan?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk-loan) |
| [`@acala-network/sdk-homa`](./packages/sdk-homa) | Liquid staking (LDOT/LKSM) operations | [![npm](https://img.shields.io/npm/v/@acala-network/sdk-homa?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk-homa) |
| [`@acala-network/sdk-payment`](./packages/sdk-payment) | Transaction fee management | [![npm](https://img.shields.io/npm/v/@acala-network/sdk-payment?style=flat-square)](https://www.npmjs.com/package/@acala-network/sdk-payment) |
| [`@acala-network/wormhole-portal`](./packages/wormhole-portal) | Cross-chain bridge operations | [![npm](https://img.shields.io/npm/v/@acala-network/wormhole-portal?style=flat-square)](https://www.npmjs.com/package/@acala-network/wormhole-portal) |

- Install dependencies
## 🚀 Quick Start

### Installation

```bash
yarn add @polkadot/api @acala-network/api@beta
# Install the main SDK
npm install @acala-network/sdk @acala-network/types @polkadot/api

# Or with yarn
yarn add @acala-network/sdk @acala-network/types @polkadot/api
```

- Create API instance
### Basic Usage

```ts
import { ApiPromise } from '@polkadot/api';
import { WsProvider } from '@polkadot/rpc-provider';
```typescript
import { ApiPromise, WsProvider } from '@polkadot/api';
import { options } from '@acala-network/api';
import { Wallet } from '@acala-network/sdk';

async function main() {
const provider = new WsProvider('wss://karura.api.onfinality.io/public-ws');
const api = new ApiPromise(options({ provider }));
await api.isReady;
// Connect to Acala network
const provider = new WsProvider('wss://acala-rpc.aca-api.network');
const api = await ApiPromise.create(options({ provider }));

// use api
}
// Create wallet instance
const wallet = new Wallet(api);

main()
// Get account balance
const address = '5F98oWfz2r5rcRVnP9VCndg33DAAsky3iuoBSpaPUbgN9AJn';
const accountInfo = await wallet.queryBalance(address);
console.log('ACA Balance:', accountInfo.native.available.toString());

// Subscribe to balance changes
wallet.subscribeBalance(address, (balance) => {
console.log('Balance updated:', balance.native.available.toString());
});
```

- Use api to interact with node
## 📚 Documentation

- 📖 **[SDK Documentation](./packages/sdk/README.md)** - Complete API reference
- 🏠 **[Homa Liquid Staking](./packages/sdk/docs/homa.md)** - Liquid staking guide
- 🌉 **[Cross-Chain Operations](./packages/sdk/docs/cross-chain.md)** - Bridge functionality
- 🔄 **[aUSD Bridge](./packages/sdk/docs/ausd-bridge.md)** - aUSD cross-chain transfers
- 🎨 **[NFT Operations](./packages/sdk/docs/nft.md)** - NFT minting and trading

## 🛠️ Development

### Prerequisites

- Node.js ≥ 22
- Yarn 4.x

### Setup

```ts
// query and display account data
const data = await api.query.system.account('5F98oWfz2r5rcRVnP9VCndg33DAAsky3iuoBSpaPUbgN9AJn');
console.log(data.toHuman())
```bash
# Clone the repository
git clone https://github.com/AcalaNetwork/acala.js.git
cd acala.js

# Install dependencies
yarn install

# Build all packages
yarn build

# Run tests
yarn test

# Lint code
yarn lint
```

# Packages
### Project Structure

- [api](./packages/api)
- Contains necessary options to create a polkadot.js API instance
- [types](./packages/types)
- Polkadot.js type definations for Acala Network
```
acala.js/
├── packages/
│ ├── sdk/ # Main SDK package
│ ├── sdk-core/ # Core utilities
│ ├── sdk-swap/ # DEX operations
│ ├── sdk-loan/ # CDP management
│ ├── sdk-homa/ # Liquid staking
│ ├── sdk-payment/ # Fee management
│ └── wormhole-portal/ # Cross-chain bridge
├── docs/ # Documentation
└── examples/ # Example applications
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "4.1.14",
"version": "4.1.15",
"private": true,
"engines": {
"node": ">=16"
"node": ">=22"
},
"workspaces": [
"packages/*"
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk-core",
"version": "4.1.14",
"version": "4.1.15",
"description": "the core of acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,11 +40,11 @@
},
"peerDependencies": {
"@acala-network/types": "^6",
"@polkadot/api": "^12"
"@polkadot/api": "^16"
},
"dependencies": {
"@acala-network/types": "^6.1.1",
"@polkadot/api": "^12.1.1",
"@acala-network/types": "^6.3.0",
"@polkadot/api": "^16.4.8",
"bignumber.js": "^9.0.0",
"lodash": "^4.17.20"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-homa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk-homa",
"version": "4.1.14",
"version": "4.1.15",
"description": "the homa sub module in acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,12 +40,12 @@
},
"peerDependencies": {
"@acala-network/types": "^6",
"@polkadot/api": "^12"
"@polkadot/api": "^16"
},
"dependencies": {
"@acala-network/sdk-core": "workspace:*",
"@acala-network/types": "^6.0.4",
"@polkadot/api": "^12.1.1",
"@acala-network/types": "^6.3.0",
"@polkadot/api": "^16.4.8",
"lodash": "^4.17.20",
"rxjs": "^7.8.1"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-loan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk-loan",
"version": "4.1.14",
"version": "4.1.15",
"description": "the loan sub module in acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,13 +40,13 @@
},
"peerDependencies": {
"@acala-network/types": "^6",
"@polkadot/api": "^12"
"@polkadot/api": "^16"
},
"dependencies": {
"@acala-network/sdk": "workspace:*",
"@acala-network/sdk-core": "workspace:*",
"@acala-network/types": "^6.0.4",
"@polkadot/api": "^12.1.1",
"@acala-network/types": "^6.3.0",
"@polkadot/api": "^16.4.8",
"lodash": "^4.17.20",
"rxjs": "^7.8.1"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-payment/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk-payment",
"version": "4.1.14",
"version": "4.1.15",
"description": "the payment acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"peerDependencies": {
"@acala-network/types": "^6",
"@polkadot/api": "^12"
"@polkadot/api": "^16"
},
"dependencies": {
"@acala-network/sdk": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk-swap",
"version": "4.1.14",
"version": "4.1.15",
"description": "the swap sub module in acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -40,13 +40,13 @@
},
"peerDependencies": {
"@acala-network/types": "^6",
"@polkadot/api": "^12"
"@polkadot/api": "^16"
},
"dependencies": {
"@acala-network/sdk": "workspace:*",
"@acala-network/sdk-core": "workspace:*",
"@acala-network/types": "^6.0.4",
"@polkadot/api": "^12.1.1",
"@acala-network/types": "^6.3.0",
"@polkadot/api": "^16.4.8",
"rxjs": "^7.8.1"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/sdk",
"version": "4.1.14",
"version": "4.1.15",
"description": "acala network sdk",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -50,16 +50,16 @@
},
"homepage": "https://github.com/AcalaNetwork/acala.js",
"peerDependencies": {
"@acala-network/api": "^5",
"@acala-network/api": "^6",
"@acala-network/eth-providers": "~2.7.18",
"@polkadot/api": "^12",
"@polkadot/api": "^16",
"ethers": "~5.7.0"
},
"dependencies": {
"@acala-network/api": "^6.1.1",
"@acala-network/api": "^6.3.0",
"@acala-network/eth-providers": "~2.7.18",
"@acala-network/sdk-core": "workspace:*",
"@polkadot/api": "^12.1.1",
"@polkadot/api": "^16.4.8",
"axios": "^0.24.0",
"ethers": "~5.7.0",
"graphql": "^16.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/wallet/vesting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Option, Vec } from '@polkadot/types';
import {
OrmlVestingVestingSchedule,
PalletBalancesBalanceLock,
PolkadotPrimitivesV6PersistedValidationData
PolkadotPrimitivesV8PersistedValidationData
} from '@polkadot/types/lookup';
import { combineLatest, firstValueFrom, map, Observable } from 'rxjs';
import { TokenProvider } from '../token-provider/type.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class Vesting {
params: [address]
}).observable;
// get parachain block api.query.parachainSystem.validationData()
const parachain$ = Storage.create<Option<PolkadotPrimitivesV6PersistedValidationData>>({
const parachain$ = Storage.create<Option<PolkadotPrimitivesV8PersistedValidationData>>({
api: this.api,
path: 'query.parachainSystem.validationData',
params: []
Expand Down
10 changes: 5 additions & 5 deletions packages/wormhole-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acala-network/wormhole-portal",
"version": "4.1.14",
"version": "4.1.15",
"description": "the wormhole wrapper for acala/karura network",
"author": "Acala Developers <hello@acala.network>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -39,20 +39,20 @@
}
},
"peerDependencies": {
"@acala-network/api": "^5",
"@acala-network/api": "^6",
"@acala-network/eth-providers": "~2.7.18",
"@polkadot/api": "^12",
"@polkadot/api": "^16",
"ethers": "~5.7.0"
},
"dependencies": {
"@acala-network/api": "^6.1.1",
"@acala-network/api": "^6.3.0",
"@acala-network/eth-providers": "~2.7.18",
"@acala-network/sdk": "workspace:*",
"@certusone/wormhole-sdk": "^0.5.0",
"@ethersproject/bignumber": "^5.7.0",
"@grpc/grpc-js": "^1.6.8",
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
"@polkadot/api": "^12.1.1",
"@polkadot/api": "^16.4.8",
"bn.js": "^5.2.1",
"ethers": "~5.7.0"
},
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"esModuleInterop": true,
"lib": ["esnext", "dom", "dom.iterable"],
"isolatedModules": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand Down
Loading
Loading