-
-
Notifications
You must be signed in to change notification settings - Fork 10
Running Commands in Adamant library
You can use Adamant-console as a library for NodeJS, but the preferred way to interact with Adamant via JavaScript is adamant-api-jsclient.
To begin with, you need to install and configure adamant-console (see wiki for details). Then import the module into your code:
const adamantApi = require('adamant-console');
Example of using:
const adamantApi = require('adamant-console');
adamantApi.getNodeVersion()
.then((res) => {
console.log(res);
process.exit();
})
.catch((err) => console.error(err));
Creates a new Adamant account
Example:
const res = adamantApi.createAccount();
console.log(res);
Registers user account as delegate
Parameters:
-
username
- Delegate name you want to register with. It must be unique in ADAMANT blockchain. It should not be similar to ADAMANT address. Delegate name can only contain alphanumeric characters and symbols !@$&_. -
passphrase
- (optional, if set in the config) account passphrase
Example:
adamantApi.createDelegate('username')
.then((res) => console.log(res));
Gets actual account's information in ADAMANT blockchain
Parameters:
-
address
- ADAMANT address starting withU
, string
Example:
adamantApi.getAddress('U777355171330060015')
.then((res) => console.log(res));
Gets full information about special block of ADAMANT chain
Parameters:
-
id
- block's id
Example:
adamantApi.getBlock('11114690216332606721')
.then((res) => console.log(res));
Gets list of blocks in ADAMANT chain
Parameters:
-
...queries
- parameters for getting request in the formatlimit=1
. See Transactions Query Language
Example:
adamantApi.getBlocks('limit=5', 'offset=12')
.then((res) => console.log(res));
Gets delegate
Parameters:
-
username
- delegate's username
Example:
adamantApi.getDelegate('lynx')
.then((res) => console.log(res));
Gets information about specific transaction's asset with transaction id
as a parameter.
Parameters:
-
id
- transaction id
Example:
adamantApi.getMessage('12154642911137703318')
.then((res) => console.log(res));
Gets information about specific transaction with transaction id
as a parameter.
Parameters:
-
id
- transaction id
Example:
adamantApi.getTransaction('12154642911137703318')
.then((res) => console.log(res));
Gets information about the transactions.
Parameters:
-
...queries
- parameters for getting request in the formatlimit=1
. See Transactions Query Language
Example:
adamantApi.getTransactions('limit=1')
.then((res) => console.log(res));
Gets information about the transactions in the specified block by id.
Parameters:
-
blockId
- block's id
Example:
adamantApi.getTransactionsInBlockById('12154642911137703318')
.then((res) => console.log(res));
Gets information about the transactions in the specified block by height.
Parameters:
-
height
- block's height
Example:
adamantApi.getTransactionsInBlockByHeight('12154642911137703318')
.then((res) => console.log(res));
Gets information about the received transactions by address.
Parameters:
-
address
- block's address
Example:
adamantApi.getTransactionsReceivedByAddress('12154642911137703318')
.then((res) => console.log(res));
Gets the current node height
Example:
adamantApi.getNodeHeight()
.then((res) => console.log(res));
Gets the current node version
Example:
adamantApi.getNodeVersion()
.then((res) => console.log(res));
Creates Token Transfer transaction, signs it, and broadcasts to ADAMANT network. See https://github.com/Adamant-im/adamant/wiki/Transaction-Types#type-0-token-transfer-transaction
Example:
adamantApi.sendTokens(
'U6386412615727665758',
'10000ADM',
'only ladder great same figure click organ metal main tide expand protect',
)
.then((res) => console.log(res));
sendMessage: (address: String, message: String, amountString?: String, passphrase?: String) => Promise
Encrypts a message, creates Message transaction, signs it, and broadcasts to ADAMANT network.
Example:
adamantApi.sendMessage(
'U6386412615727665758',
{/* message object */},
'10000ADM',
'only ladder great same figure click organ metal main tide expand protect',
)
.then((res) => console.log(res));
Encrypts a rich message, creates Message transaction, signs it, and broadcasts to ADAMANT network.
Example:
adamantApi.sendRich(
'U6386412615727665758',
{/* rich message object */},
'only ladder great same figure click organ metal main tide expand protect',
)
.then((res) => console.log(res));
Encrypts a signal message, creates Message transaction, signs it, and broadcasts to ADAMANT network.
Example:
adamantApi.sendSignal(
'U6386412615727665758',
{/* signal message object */},
'only ladder great same figure click organ metal main tide expand protect',
)
.then((res) => console.log(res));
Creates Vote For Delegate transactions, signs it, and broadcasts to ADAMANT network.
Parameters:
-
delegates
- PublicKeys, ADM addresses and delegate names for upvote and downvote. Downvote vote should contain-
in first place. It would be more efficient to pass publicKey, otherwise the api will make additional queries -
passPhrase
- (optional, if set in the config) account pass phrase
Example:
adamantApi.voteFor(
[
'lynx',
'+U777355171330060015',
'-a9407418dafb3c8aeee28f3263fd55bae0f528a5697a9df0e77e6568b19dfe34'
],
'only ladder great same figure click organ metal main tide expand protect',
)
.then((res) => console.log(res));