Skip to main content
Version: IOTA

api_reference

Classes

AddressGetter
BalanceGetter
Client
ClientBuilder
GetAddressBuilder
MessageBuilder
MessageGetter
UnspentAddressGetter

Functions

start()

Initializes the console error panic hook for better error messages

AddressGetter

Kind: global class

addressGetter.accountIndex(index) ⇒ AddressGetter

Set the account index

Kind: instance method of AddressGetter

ParamType
indexnumber

addressGetter.range(start, end) ⇒ AddressGetter

Set the address range

Kind: instance method of AddressGetter

ParamType
startnumber
endnumber

addressGetter.bech32Hrp(bech32_hrp) ⇒ AddressGetter

Set the bech32 hrp

Kind: instance method of AddressGetter

ParamType
bech32_hrpstring

addressGetter.includeInternal() ⇒ AddressGetter

Include internal addresses

Kind: instance method of AddressGetter

addressGetter.get() ⇒ Promise.<any>

Get the addresses.

Kind: instance method of AddressGetter

AddressGetter.new(client, seed) ⇒ AddressGetter

Kind: static method of AddressGetter

ParamType
clientClient
seedstring

BalanceGetter

Kind: global class

balanceGetter.accountIndex(index) ⇒ BalanceGetter

Sets the account index

Kind: instance method of BalanceGetter

ParamType
indexnumber

balanceGetter.initialAddressIndex(initial_address_index) ⇒ BalanceGetter

Sets the address index from which to start looking for balance

Kind: instance method of BalanceGetter

ParamType
initial_address_indexnumber

balanceGetter.gap_limit(gap_limit) ⇒ BalanceGetter

Sets the gap limit to specify how many addresses will be checked each round. If gap_limit amount of addresses in a row have no balance the function will return.

Kind: instance method of BalanceGetter

ParamType
gap_limitnumber

balanceGetter.get() ⇒ Promise.<any>

Get the balance.

Kind: instance method of BalanceGetter

BalanceGetter.new(client, seed) ⇒ BalanceGetter

Kind: static method of BalanceGetter

ParamType
clientClient
seedstring

Client

Kind: global class

client.message() ⇒ MessageBuilder

Send a message to the Tangle.

Kind: instance method of Client

client.getMessage() ⇒ MessageGetter

Get a message from the Tangle.

Kind: instance method of Client

client.getAddresses(seed) ⇒ AddressGetter

Generate addresses.

Kind: instance method of Client

ParamType
seedstring

client.getUnspentAddress(seed) ⇒ UnspentAddressGetter

Get an unspent address.

Kind: instance method of Client

ParamType
seedstring

client.getBalance(seed) ⇒ BalanceGetter

Get the account balance.

Kind: instance method of Client

ParamType
seedstring

client.getAddress() ⇒ GetAddressBuilder

GET /api/v1/addresses/{address} endpoint

Kind: instance method of Client

client.getInfo() ⇒ Promise.<any>

Get the nodeinfo.

Kind: instance method of Client

client.getNodeInfo(url, jwt, username, password) ⇒ Promise.<any>

Get the nodeinfo.

Kind: instance method of Client

ParamType
urlstring
jwtstring | undefined
usernamestring | undefined
passwordstring | undefined

client.networkInfo() ⇒ Promise.<any>

Gets the network related information such as network_id and min_pow_score and if it's the default one, sync it first.

Kind: instance method of Client

client.getNetworkId() ⇒ Promise.<any>

Gets the network id of the node we're connecting to.

Kind: instance method of Client

client.getBech32Hrp() ⇒ Promise.<any>

returns the bech32_hrp

Kind: instance method of Client

client.getMinPowScore() ⇒ Promise.<any>

returns the bech32_hrp

Kind: instance method of Client

client.getHealth() ⇒ Promise.<any>

Get the node health.

Kind: instance method of Client

client.getTips() ⇒ Promise.<any>

Get tips.

Kind: instance method of Client

client.getPeers() ⇒ Promise.<any>

Get peers.

Kind: instance method of Client

client.getOutput(output_id) ⇒ Promise.<any>

GET /api/v1/outputs/{outputId} endpoint Find an output by its transaction_id and corresponding output_index.

Kind: instance method of Client

ParamType
output_idstring

client.findMessages(indexation_keys, message_ids) ⇒ Promise.<any>

Find all messages by provided message IDs and/or indexation_keys.

Kind: instance method of Client

ParamType
indexation_keysany
message_idsany

client.findInputs(addresses, amount) ⇒ Promise.<any>

Function to find inputs from addresses for a provided amount (useful for offline signing)

Kind: instance method of Client

ParamType
addressesany
amountBigInt

client.findOutputs(outputs, addresses) ⇒ Promise.<any>

Find all outputs based on the requests criteria. This method will try to query multiple nodes if the request amount exceeds individual node limit.

Kind: instance method of Client

ParamType
outputsany
addressesany

client.getAddressBalances(addresses) ⇒ Promise.<any>

Return the balance in iota for the given addresses; No seed needed to do this since we are only checking and already know the addresses.

Kind: instance method of Client

ParamType
addressesany

client.getMilestone(index) ⇒ Promise.<any>

GET /api/v1/milestones/{index} endpoint Get the milestone by the given index.

Kind: instance method of Client

ParamType
indexnumber

client.getMilestoneUtxoChanges(index) ⇒ Promise.<any>

GET /api/v1/milestones/{index}/utxo-changes endpoint Get the milestone by the given index.

Kind: instance method of Client

ParamType
indexnumber

client.getReceipts() ⇒ Promise.<any>

GET /api/v1/receipts endpoint Get all receipts.

Kind: instance method of Client

client.getReceiptsMigratedAt(milestone_index) ⇒ Promise.<any>

GET /api/v1/receipts/{migratedAt} endpoint Get the receipts by the given milestone index.

Kind: instance method of Client

ParamType
milestone_indexnumber

client.getTreasury() ⇒ Promise.<any>

GET /api/v1/treasury endpoint Get the treasury output.

Kind: instance method of Client

client.getIncludedMessage(transaction_id) ⇒ Promise.<any>

GET /api/v1/transactions/{transactionId}/included-message Returns the included message of the transaction.

Kind: instance method of Client

ParamType
transaction_idstring

client.postMessage(message) ⇒ Promise.<any>

Post message.

Kind: instance method of Client

ParamType
messageany

client.retry(message_id) ⇒ Promise.<any>

Retries (promotes or reattaches) a message for provided message id. Message should only be retried only if they are valid and haven't been confirmed for a while.

Kind: instance method of Client

ParamType
message_idstring

client.retryUntilIncluded(message_id, interval, max_attempts) ⇒ Promise.<any>

Only works in browser because of the timeouts Retries (promotes or reattaches) a message for provided message id until it's included (referenced by a milestone). Default interval is 5 seconds and max attempts is 40. Returns reattached messages

Kind: instance method of Client

ParamType
message_idstring
intervalBigInt | undefined
max_attemptsBigInt | undefined

client.reattach(message_id) ⇒ Promise.<any>

Reattaches messages for provided message id. Messages can be reattached only if they are valid and haven't been confirmed for a while.

Kind: instance method of Client

ParamType
message_idstring

client.promote(message_id) ⇒ Promise.<any>

Promotes a message. The method should validate if a promotion is necessary through get_message. If not, the method should error out and should not allow unnecessary promotions.

Kind: instance method of Client

ParamType
message_idstring

client.consolidateFunds(seed, account_index, start_index, end_index) ⇒ Promise.<any>

Only works in browser because of the timeouts Function to consolidate all funds from a range of addresses to the address with the lowest index in that range Returns the address to which the funds got consolidated, if any were available

Kind: instance method of Client

ParamType
seedstring
account_indexnumber
start_indexnumber
end_indexnumber

client.bech32ToHex(address) ⇒ string

Returns a parsed hex String from bech32.

Kind: instance method of Client

ParamType
addressstring

client.hexToBech32(address, bech32) ⇒ Promise.<any>

Returns a parsed bech32 String from hex.

Kind: instance method of Client

ParamType
addressstring
bech32string | undefined

client.hexPublicKeyToBech32Address(public_key, bech32) ⇒ Promise.<any>

Transforms a hex encoded public key to a bech32 encoded address

Kind: instance method of Client

ParamType
public_keystring
bech32string | undefined

client.isAddressValid(address) ⇒ boolean

Checks if a String is a valid bech32 encoded address.

Kind: instance method of Client

ParamType
addressstring

client.generateMnemonic() ⇒ string

Generates a new mnemonic.

Kind: instance method of Client

client.mnemonicToHexSeed(mnemonic) ⇒ string

Returns a hex encoded seed for a mnemonic.

Kind: instance method of Client

ParamType
mnemonicstring

client.getMessageId(message) ⇒ string

Returns the message id from a provided message.

Kind: instance method of Client

ParamType
messagestring

client.getTransactionId(transaction) ⇒ string

Returns the transaction id from a provided transaction payload.

Kind: instance method of Client

ParamType
transactionstring

client.getEssenceHash(essence) ⇒ string

Get essence hash

Kind: instance method of Client

ParamType
essencestring

ClientBuilder

Kind: global class

new ClientBuilder()

Creates an IOTA client builder.

clientBuilder.node(url) ⇒ ClientBuilder

Adds an IOTA node by its URL.

Kind: instance method of ClientBuilder

ParamType
urlstring

clientBuilder.primaryNode(url, jwt, username, password) ⇒ ClientBuilder

Adds an IOTA node by its URL to be used as primary node, with optional jwt and or basic authentication

Kind: instance method of ClientBuilder

ParamType
urlstring
jwtstring | undefined
usernamestring | undefined
passwordstring | undefined

clientBuilder.primaryPowNode(url, jwt, username, password) ⇒ ClientBuilder

Adds an IOTA node by its URL to be used as primary PoW node (for remote PoW), with optional jwt and or basic authentication

Kind: instance method of ClientBuilder

ParamType
urlstring
jwtstring | undefined
usernamestring | undefined
passwordstring | undefined

clientBuilder.permanode(url, jwt, username, password) ⇒ ClientBuilder

Adds a permanode by its URL, with optional jwt and or basic authentication

Kind: instance method of ClientBuilder

ParamType
urlstring
jwtstring | undefined
usernamestring | undefined
passwordstring | undefined

clientBuilder.nodeAuth(url, jwt, username, password) ⇒ ClientBuilder

Adds an IOTA node by its URL with optional jwt and or basic authentication

Kind: instance method of ClientBuilder

ParamType
urlstring
jwtstring | undefined
usernamestring | undefined
passwordstring | undefined

clientBuilder.nodes(urls) ⇒ ClientBuilder

Adds a list of IOTA nodes by their URLs.

Kind: instance method of ClientBuilder

ParamType
urlsany

clientBuilder.nodeSyncInterval(value) ⇒ ClientBuilder

Set the node sync interval (has no effect because we can't spawn another thread in wasm to sync the nodes)

Kind: instance method of ClientBuilder

ParamType
valuenumber

clientBuilder.nodeSyncDisabled() ⇒ ClientBuilder

Disables the node syncing process. Every node will be considered healthy and ready to use.

Kind: instance method of ClientBuilder

clientBuilder.offlineMode() ⇒ ClientBuilder

Allows creating the client without nodes for offline address generation or signing

Kind: instance method of ClientBuilder

clientBuilder.nodePoolUrls(node_pool_urls) ⇒ Promise.<any>

Get node list from the node_pool_urls

Kind: instance method of ClientBuilder

ParamType
node_pool_urlsany

clientBuilder.quorum(value) ⇒ ClientBuilder

Set if quroum should be used or not

Kind: instance method of ClientBuilder

ParamType
valueboolean

clientBuilder.quorumSize(value) ⇒ ClientBuilder

Set amount of nodes which should be used for quorum

Kind: instance method of ClientBuilder

ParamType
valuenumber

clientBuilder.quorumThreshold(value) ⇒ ClientBuilder

Set quorum_threshold

Kind: instance method of ClientBuilder

ParamType
valuenumber

clientBuilder.network(network) ⇒ ClientBuilder

Selects the type of network to get default nodes for it, only "devnet" is supported at the moment. Nodes that don't belong to this network are ignored. Default nodes are only used when no other nodes are provided.

Kind: instance method of ClientBuilder

ParamType
networkstring

clientBuilder.localPow(value) ⇒ ClientBuilder

Since we can only have a single thread in wasm, local PoW is much slower

Kind: instance method of ClientBuilder

ParamType
valueboolean

clientBuilder.tipsInterval(value) ⇒ ClientBuilder

Sets after how many seconds new tips will be requested during PoW

Kind: instance method of ClientBuilder

ParamType
valuenumber

clientBuilder.requestTimeout(value) ⇒ ClientBuilder

Sets the default request timeout.

Kind: instance method of ClientBuilder

ParamType
valuenumber

clientBuilder.apiTimeout(api, timeout) ⇒ ClientBuilder

Sets the request timeout for a specific API usage.

Kind: instance method of ClientBuilder

ParamType
apistring
timeoutnumber

clientBuilder.build() ⇒ Promise.<any>

Build the client.

Kind: instance method of ClientBuilder

GetAddressBuilder

Kind: global class

getAddressBuilder.balance(address) ⇒ Promise.<any>

Consume the builder and get the balance of a given Bech32 encoded address. If count equals maxResults, then there might be more outputs available but those were skipped for performance reasons. User should sweep the address to reduce the amount of outputs.

Kind: instance method of GetAddressBuilder

ParamType
addressstring

getAddressBuilder.outputs(address, options) ⇒ Promise.<any>

Consume the builder and get all outputs that use a given address. If count equals maxResults, then there might be more outputs available but those were skipped for performance reasons. User should sweep the address to reduce the amount of outputs.

Kind: instance method of GetAddressBuilder

ParamType
addressstring
optionsany

GetAddressBuilder.new(client) ⇒ GetAddressBuilder

Kind: static method of GetAddressBuilder

ParamType
clientClient

MessageBuilder

Kind: global class

messageBuilder.index(index) ⇒ MessageBuilder

Set indexation to the builder

Kind: instance method of MessageBuilder

ParamType
indexUint8Array

messageBuilder.data(data) ⇒ MessageBuilder

Set data to the builder

Kind: instance method of MessageBuilder

ParamType
dataUint8Array

messageBuilder.seed(seed) ⇒ MessageBuilder

Sets the seed.

Kind: instance method of MessageBuilder

ParamType
seedstring

messageBuilder.accountIndex(account_index) ⇒ MessageBuilder

Sets the account index.

Kind: instance method of MessageBuilder

ParamType
account_indexnumber

messageBuilder.initialAddressIndex(initial_address_index) ⇒ MessageBuilder

Sets the index of the address to start looking for balance.

Kind: instance method of MessageBuilder

ParamType
initial_address_indexnumber

messageBuilder.parents(parents) ⇒ MessageBuilder

Set 1-8 custom parent message ids

Kind: instance method of MessageBuilder

ParamType
parentsany

messageBuilder.input(output_id) ⇒ MessageBuilder

Set a custom input(transaction output)

Kind: instance method of MessageBuilder

ParamType
output_idstring

messageBuilder.inputRange(start, end) ⇒ MessageBuilder

Set a custom range in which to search for addresses for custom provided inputs. Default: 0..100

Kind: instance method of MessageBuilder

ParamType
startnumber
endnumber

messageBuilder.output(address, amount) ⇒ MessageBuilder

Set a transfer to the builder

Kind: instance method of MessageBuilder

ParamType
addressstring
amountBigInt

messageBuilder.dustAllowanceOutput(address, amount) ⇒ MessageBuilder

Set a dust allowance transfer to the builder, address needs to be Bech32 encoded

Kind: instance method of MessageBuilder

ParamType
addressstring
amountBigInt

messageBuilder.prepareTransaction() ⇒ Promise.<any>

Prepare a transaction

Kind: instance method of MessageBuilder

messageBuilder.signTransaction(prepared_transaction_data, seed, input_range_start, input_range_end) ⇒ Promise.<any>

Sign a transaction

Kind: instance method of MessageBuilder

ParamType
prepared_transaction_dataany
seedstring
input_range_startnumber | undefined
input_range_endnumber | undefined

messageBuilder.finishMessage(payload) ⇒ Promise.<any>

Create a message with a provided payload

Kind: instance method of MessageBuilder

ParamType
payloadany

messageBuilder.submit() ⇒ Promise.<any>

Build and sumbit the message.

Kind: instance method of MessageBuilder

MessageBuilder.new(client) ⇒ MessageBuilder

Kind: static method of MessageBuilder

ParamType
clientClient

MessageGetter

Kind: global class

messageGetter.index(index) ⇒ Promise.<any>

Get message ids with an index.

Kind: instance method of MessageGetter

ParamType
indexUint8Array

messageGetter.data(message_id) ⇒ Promise.<any>

Get a message with the message id.

Kind: instance method of MessageGetter

ParamType
message_idstring

messageGetter.raw(message_id) ⇒ Promise.<any>

Get the raw message with the message id.

Kind: instance method of MessageGetter

ParamType
message_idstring

messageGetter.children(message_id) ⇒ Promise.<any>

Get the childrens of a message with the message id.

Kind: instance method of MessageGetter

ParamType
message_idstring

messageGetter.metadata(message_id) ⇒ Promise.<any>

Get the metadata of a message with the message id.

Kind: instance method of MessageGetter

ParamType
message_idstring

MessageGetter.new(client) ⇒ MessageGetter

Kind: static method of MessageGetter

ParamType
clientClient

UnspentAddressGetter

Kind: global class

unspentAddressGetter.accountIndex(index) ⇒ UnspentAddressGetter

Sets the account index

Kind: instance method of UnspentAddressGetter

ParamType
indexnumber

unspentAddressGetter.initialAddressIndex(index) ⇒ UnspentAddressGetter

Sets the index of the address to start looking for balance

Kind: instance method of UnspentAddressGetter

ParamType
indexnumber

unspentAddressGetter.get() ⇒ Promise.<any>

Get an unspent address with its index.

Kind: instance method of UnspentAddressGetter

UnspentAddressGetter.new(client, seed) ⇒ UnspentAddressGetter

Kind: static method of UnspentAddressGetter

ParamType
clientClient
seedstring

start()

Initializes the console error panic hook for better error messages

Kind: global function