Constructor
new FederationServer(serverURL, domain, optsopt) → {void}
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
serverURL |
string
|
The federation server URL (ex. |
|||||||||||||
domain |
string
|
Domain this server represents |
|||||||||||||
opts |
object
|
<optional> |
options object
|
Returns:
- Type:
-
void
Methods
(static) createForDomain(domain, optsopt) → {Promise}
Creates a FederationServer
instance based on information from
stellar.toml
file for a given domain.
If stellar.toml
file does not exist for a given domain or it does not
contain information about a federation server Promise will reject.
StellarSdk.FederationServer.createForDomain('acme.com')
.then(federationServer => {
// federationServer.resolveAddress('bob').then(...)
})
.catch(error => {
// stellar.toml does not exist or it does not contain information about federation server.
});
- Source:
- See:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
domain |
string
|
Domain to get federation server for |
|||||||||||||
opts |
object
|
<optional> |
Options object
|
Returns:
- Type:
-
Promise
Promise
that resolves to a FederationServer object
(static) resolve(value, optsopt) → {Promise}
A helper method for handling user inputs that contain destination
value.
It accepts two types of values:
- For Stellar address (ex.
bob*stellar.org
) it splits Stellar address and then tries to find information about federation server instellar.toml
file for a given domain. It returns aPromise
which resolves if federation server exists and user has been found and rejects in all other cases. - For Account ID (ex.
GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS
) it returns aPromise
which resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check if the account actually exists in a ledger.
Example:
StellarSdk.FederationServer.resolve('bob*stellar.org')
.then(federationRecord => {
// {
// account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',
// memo_type: 'id',
// memo: 100
// }
});
- Source:
- See:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
string
|
Stellar Address (ex. |
|||||||||||||
opts |
object
|
<optional> |
Options object
|
Returns:
- Type:
-
Promise
Promise
that resolves to a JSON object with this shape:
account_id
- Account ID of the destination,memo_type
(optional) - Memo type that needs to be attached to a transaction,memo
(optional) - Memo value that needs to be attached to a transaction.
resolveAccountId(accountId) → {Promise}
Given an account ID, get their federation record if the user was found
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
accountId |
string
|
Account ID (ex. |
Returns:
- Type:
-
Promise
A promise that resolves to the federation record
resolveAddress(address) → {Promise}
Get the federation record if the user was found for a given Stellar address
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
address |
string
|
Stellar address (ex. |
Returns:
- Type:
-
Promise
Promise that resolves to the federation record
resolveTransactionId(transactionId) → {Promise}
Given a transactionId, get the federation record if the sender of the transaction was found
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
transactionId |
string
|
Transaction ID (ex. |
Returns:
- Type:
-
Promise
A promise that resolves to the federation record