Methods
balance(Addressopt)
Get the balance of the given coin or token. Internally, these functions call tokenBalance or coinBalance, depending on if the object is a coin or token. You might find it useful to refer to tokenBalance and coinBalance individually. Returns a Live Structure
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
Address |
string |
<optional> |
The address of the given coin or token. If none are provided, the instances address is used. |
block(lookbackopt, onlyOldestopt) → {array}
Get a number of very recent blocks in an array. The first element of the array is the oldest block.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
lookback |
integer |
<optional> |
The number of blocks to return from the most recent. Default: 0 |
onlyOldest |
boolean |
<optional> |
If true, returns only the oldest of these blocks as an object |
Returns:
Blocks Returns an array, unless onlyOldest is selected, then a block object is returned.
- Type
- array
(async) build()
Connect to the WebSocket network for your blockchain, and assign global variables to track its last 10 blocks in .Blocks and its fee/gas-price in .Fee. Note that balances, history, and other information is not yet tracked.
fee()
The current fee, or gas price, for your coin is always stored in the .fee constant. If you'd like to get the average fee over a greater number of blocks, you can do that here. By default, this will update the .fee constant for this coin instance.
history(Addressopt)
List all transactions for an address
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
Address |
string |
<optional> |
A cryptocurrency address, or the instance's address is used |
(async) price("USD"opt, "COIN"opt)
Get the USD price, or other fiat price, of a coin or token. May not work for some tokens. Needs to be turned into Live structure.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
"USD" |
string |
<optional> |
The fiat to compare your coin or token to |
"COIN" |
string |
<optional> |
The symbol of the coin or token (will default to token symbol / coin. |
stableBlock() → {object}
Get the latest stable block (one that is unlikely to be lost due to re-org / "uncle").
Returns:
Block A block object with number, hash, and timestamp (server time in seconds).
- Type
- object
(async) token(TokenID)
Performs the functions in .coin, as well as assigning the token information (decimals, symbol, etc) to your token structure. Note that balances, history, and other information is not yet tracked.
Parameters:
| Name | Type | Description |
|---|---|---|
TokenID |
string | The address of the genesis Tx or similar structure that uniquely identifies a token. |
(async) transaction(TxJSON)
Build, send, or sign a transaction. For 'on', 'get', and 'is' methods, the number of confirmations of a transaction hash is calculated.
Parameters:
| Name | Type | Description |
|---|---|---|
TxJSON |
object | A JSON structure / dictionary / unordered list. Required keys: toAddress, amount (in decimals, will be converted to wei / satoshi / tokenDecimals when returned). Optional: privateKey(string) --> if you don't provide this, the one for your current coin/token will be used. data(json-object or string)--> data to embed in the blockchain, can create large transactions on btc /bch. .hash --> May contain a hash structure |