Class

Network

Findora-Network~Network(protocol, host, queryPort, submitPort, ledgerPort)

Constructor

# new Network(protocol, host, queryPort, submitPort, ledgerPort)

Creates an new Network object.

Parameters:
Name Type Description
protocol string

Network protocol (e.g. http).

host string

Hostname (e.g. localhost, staging.findora.org or testnet.findora.org).

queryPort int

Query server port.

submitPort int

Submission server port.

ledgerPort int

Ledger server port.

View Source network.js, line 19

Methods

# async getAIRResult(key)

If successful, returns a promise that will eventually provide a JSON-encoded AIR result object.

Parameters:
Name Type Description
key String

Stringified credential user key.

View Source network.js, line 181

# async getAsset(code)

If successful, returns a promise that will eventually provide a JSON-encoded object representing the asset definition, including properties and other information.

See getAssetProperties about how to get the asset properties.

Parameters:
Name Type Description
code int

Asset token code.

View Source network.js, line 113

Will throw an error if the asset information cannot be fetched from the server.

# async getAssetProperties(code)

If successful, returns a promise that will eventually provide a JSON-encoded object representing the asset properties, including: code, issuer, memo, and asset_rules.

Asset properties are part of the asset definition. Use getAsset to get the asset definition.

Parameters:
Name Type Description
code int

Asset token code.

View Source network.js, line 141

Will throw an error if the asset information cannot be fetched from the server.

# async getCreatedAssets(address)

If successful, returns a list of asset codes created by the given address.

Parameters:
Name Type Description
address string

Base64 encoded address string.

View Source network.js, line 248

Will throw an error if the created assets cannot be fetched from the server.

# async getCustomData(key)

If successful, returns the custom data stored by the query server at a certain key.

Parameters:
Name Type Description
key string

Base64 encoded custom data key.

See:
  • Key for instructions on generating a custom data key.
  • add_operation_kv_update_with_hash for instructions on adding a hash to the ledger's custom data store.
  • storeCustomData for instructions on how to store custom data on the query server.

View Source network.js, line 277

# async getCustomDataHash(key)

If successful, returns the hash stored by the ledger's custom data store at the provided key.

Parameters:
Name Type Description
key string

Base64 encoded custom data key.

See:
  • Key for instructions on generating a custom data key.
  • add_operation_kv_update_with_hash for instructions on adding a hash to the ledger's custom data store.

View Source network.js, line 326

# async getIssuanceNum(code)

If successful, returns a promise that will eventually provide the asset issuance number for a provided asset.

Parameters:
Name Type Description
code String

Asset token code.

View Source network.js, line 125

Will throw an error if the asset issuance number cannot be fetched from the server.

# async getIssuedRecords(address)

If successful, returns a list of records issued by the given address.

Parameters:
Name Type Description
address string

Base64 encoded address string.

View Source network.js, line 311

Will throw an error if the issued record list cannot be fetched from the server.

# async getOwnedSids(address)

If successful, returns a list of UTXO SIDs owned by the given address.

Note: this is different from getRelatedSids which returns a list of transaction SIDs.

Parameters:
Name Type Description
address string

Base64 encoded address string.

View Source network.js, line 224

Will throw an error if the utxo list cannot be fetched from the server.

# async getOwnerMemo(utxoSid)

If successful, returns a list of UTXO SIDs owned by the given address.

Parameters:
Name Type Description
utxoSid int

UTXO SID, which can be fetched by getOwnedSids.

View Source network.js, line 236

Will throw an error if the owner memo cannot be fetched from the server.

# async getRelatedSids(address)

If successful, returns a list of transaction SIDs related to the given address.

Note: this is different from getOwnedSids which returns a list of UTXO SIDs.

Parameters:
Name Type Description
address string

Base64 encoded address string.

View Source network.js, line 195

Will throw an error if the utxo list cannot be fetched from the server.

# async getRelatedXfrs(code)

If successful, returns a list of transfer transaction SIDs related to the given asset token code.

Note: a transfer transaction is ralted to an asset token code if the asset is transferred nonconfidentially in the transaction.

Parameters:
Name Type Description
code string

Asset token code.

View Source network.js, line 209

Will throw an error if the asset information cannot be fetched from the server.

# async getStateCommitment()

If successful, returns a promise that will eventually provide a JSON-encoded object representing the state commitment of the ledger.

View Source network.js, line 153

Will throw an error if the state commitment cannot be fetched from the server.

# async getTracedAssets(address)

If successful, returns a list of asset codes traced by the given address.

Parameters:
Name Type Description
address string

Base64 encoded address string.

View Source network.js, line 260

Will throw an error if the created assets cannot be fetched from the server.

# async getTxn(txnSid)

If successful, returns a promise that will eventually provide a JSON-encoded transaction object. Otherwise, returns 'not found'. The request fails if the transaction index does not correspond to a transaction.

Parameters:
Name Type Description
txnSid int

Transaction SID, which can be fetched by getRelatedSids.

View Source network.js, line 97

Will throw an error if the transaction cannot be fetched from the server.

# async getTxnStatus(handle)

Given a transaction handle, returns a promise that will eventually provide the status of a transaction that has been submitted to the submission server.

Parameters:
Name Type Description
handle handle

Transaction handle string.

View Source network.js, line 60

# async getUtxo(utxoSid)

If successful, returns a promise that will eventually provide a JSON-encoded utxo object, which can be used to construct a ClientAssetRecord.

Parameters:
Name Type Description
utxoSid int

UTXO SID, which can be fetched by getOwnedSids.

View Source network.js, line 169

Will throw an error if the utxo at the given index cannot be fetched from the ledger server.

# async storeCustomData(customData)

If successful, stores data on the query server that matches the hash stored in the ledger's custom data store.

Parameters:
Name Type Description
customData Array

Array containing a base64-encoded key, byte array representing the data, and a JSON blind.

See:
  • Key for instructions on generating a custom data key.
  • KVBlind for instructions on generating a blind.
  • add_operation_kv_update_with_hash for instructions on adding a hash to the ledger's custom data store.
  • getCustomData for instructions on how to fetch custom data from the query server.

View Source network.js, line 299

Will throw an error if the data provided does not hash to the hash stored by the ledger at the provided key.

# async submitTransaction(txn)

Submit a transaction to the ledger and return a promise for the ledger's eventual response. The transaction will be enqueued for validation. If it is valid, it will eventually be committed to the ledger. To determine whether or not the transaction has been committed to the ledger, query the ledger by transaction handle. Contained in the response of submit_transaction is a TransactionHandle that can be used to query the status of the transaction.

Parameters:
Name Type Description
txn txn

JSON-encoded transaction string.

View Source network.js, line 80