interbtc-api

@interlay/interbtc-api / Exports / DefaultTokensAPI

Class: DefaultTokensAPI

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DefaultTokensAPI(api): DefaultTokensAPI

Parameters

Name Type
api ApiPromise

Returns

DefaultTokensAPI

Defined in

src/parachain/tokens.ts:70

Properties

api

Private api: ApiPromise

Defined in

src/parachain/tokens.ts:70

Methods

balance

balance(currency, id): Promise<ChainBalance>

Parameters

Name Type Description
currency CurrencyExt The currency specification, Monetary.js object or ForeignAsset
id AccountId The AccountId of a user

Returns

Promise<ChainBalance>

The user’s balance

Implementation of

TokensAPI.balance

Defined in

src/parachain/tokens.ts:82


buildTransferExtrinsic

buildTransferExtrinsic(destination, amount): SubmittableExtrinsic<"promise", ISubmittableResult>

Build a transfer extrinsic without sending it.

Parameters

Name Type Description
destination string The address of a user
amount MonetaryAmount<CurrencyExt> The amount to transfer, as Monetary.js object or ForeignAsset

Returns

SubmittableExtrinsic<"promise", ISubmittableResult>

A transfer submittable extrinsic.

Implementation of

TokensAPI.buildTransferExtrinsic

Defined in

src/parachain/tokens.ts:111


getAccountData

getAccountData(currency, id): Promise<OrmlTokensAccountData>

Parameters

Name Type
currency CurrencyExt
id AccountId

Returns

Promise<OrmlTokensAccountData>

Defined in

src/parachain/tokens.ts:78


setBalance

setBalance(accountId, freeBalance, lockedBalance?): ExtrinsicData

Parameters

Name Type Description
accountId AccountId Account whose balance to set
freeBalance MonetaryAmount<CurrencyExt> Free balance to set, as a Monetary.js object
lockedBalance? MonetaryAmount<CurrencyExt> Locked balance to set, as a Monetary.js object

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Remarks

This extrinsic is only valid if submitted by a sudo account

Implementation of

TokensAPI.setBalance

Defined in

src/parachain/tokens.ts:129


subscribeToBalance

subscribeToBalance(currency, account, callback): Promise<() => void>

Subscribe to balance updates

Parameters

Name Type Description
currency CurrencyExt The currency specification, Monetary.js object or ForeignAsset
account string AccountId string
callback (account: string, accountData: ChainBalance) => void Function to be called whenever the balance of an account is updated. Its parameters are (accountIdString, freeBalance)

Returns

Promise<() => void>

Implementation of

TokensAPI.subscribeToBalance

Defined in

src/parachain/tokens.ts:87


total

total<CurrencyT>(currency): Promise<MonetaryAmount<CurrencyT>>

Type parameters

Name Type
CurrencyT extends CurrencyExt

Parameters

Name Type Description
currency CurrencyT The currency specification, a Monetary.js object or ForeignAsset

Returns

Promise<MonetaryAmount<CurrencyT>>

The total amount in the system

Implementation of

TokensAPI.total

Defined in

src/parachain/tokens.ts:72


transfer

transfer(destination, amount): ExtrinsicData

Parameters

Name Type Description
destination string The address of a user
amount MonetaryAmount<CurrencyExt> The amount to transfer, as Monetary.js object or ForeignAsset

Returns

ExtrinsicData

A submittable extrinsic and an event that is emitted when extrinsic is submitted.

Implementation of

TokensAPI.transfer

Defined in

src/parachain/tokens.ts:119