-
-
Notifications
You must be signed in to change notification settings - Fork 10
Running Commands in Adamant console
To run commands in ADAMANT blockchain, Adamant-console should be installed and configured.
There are 3 ways of interacting with ADAMANT blockchain using Adamant-console. You can use command-line interface (CLI), JSON-RPC, or as a JS library.
Commands can be run in interactive mode, or non-interactively.
If you run Adamant-console with simple adm
command, it will start interactive mode.
adm #will run interactive mode
Then, to exit Adamant-console, press Ctrl+C twice.
If you run Adamant-console with a particular command, it will make an action and then return to bash.
adm account new #will create new ADAMANT account and return to bash
If command needs an account to run, f. e. send tokens
, the account can be set in two ways, by editing config file, or by placing --passphrase
command parameter.
Note, that --passphrase
command parameter has more priority, than passphrase
parameter in config.
Example:
adm send tokens U15531909278942872097 1ADM --passphrase "shift credit run sea order flower tribe invest march govern blanket absorb"
Sends 1 ADM to U15531909278942872097.
You can run any command from bash, or use any programming languages to interact with Adamant-console, like PHP, Python, NodeJS. Here is an example of creating new ADAMANT account in PHP:
<?php
//If Adamant-console installed globally via NPM
$path_to_adamant_console='adm';
//If Adamant-console installed locally
//$path_to_adamant_console='node ./bin/adamant.js';
//Creating new ADAMANT wallet
exec($path_to_adamant_console.' account new', $json_answer);
//Processing result
$json_answer=implode('', $json_answer);
$answer=json_decode($json_answer);
if ($answer->success) {
echo "\n\nNew ADAMANT wallet ".$answer->account->address." is created. Its passphrase: ".$answer->account->passphrase."\n\n";
}
else {
echo "\n\nWallet was not created.\n\n";
}
If you prefer to use JSON-RPC instead of CLI, welcome. See JSON-RPC configuration and usage.
You can add Console as a dependency in a JS project.