- Docs
- Developers
- Archway daemon
Archwayd daemon
The archwayd
tool can operate as a background process (daemon), as indicated by the d
at the end of its name, and is essential for running a node on the Archway network. However, it is not limited to this function as it is the ultimate tool for allowing anyone to interact with the Archway blockchain.
Installation
The following section of the Installation documentation provides detailed instructions on how to install archwayd
for your specific environment.
Commands overview
You can view the full range of archwayd
commands by using the command archwayd --help
.
archwayd --help# Outputs:Archway Daemon (server)Usage: archwayd [command]Available Commands: config Create or query an application CLI configuration file debug Tool for helping with debugging your application ensure-binary ensures the binary is correctly built export Export state to JSON genesis Application's genesis-related subcommands help Help about any command init Initialize private validator, p2p, genesis, and application configuration files keys Manage your application's keys query Querying subcommands rollback rollback cosmos-sdk and tendermint state by one height rosetta spin up a rosetta server start Run the full node status Query remote node for status tendermint Tendermint subcommands tx Transactions subcommands version Print the application binary version informationFlags: -h, --help help for archwayd --home string directory for config and data (default "/Users/adrianthompson/.archway") --log_format string The logging format (json|plain) (default "plain") --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info") --log_no_color Disable colored logs --trace print out full stack trace on errorsUse "archwayd [command] --help" for more information about a command.
Using archwayd: common commands
This section will guide you through using archwayd by providing examples of some common commands.
Create an Account
Let's start with the basics, as an account
is required for executing transactions on-chain. By executing archwayd keys --help
, you can see the list of commands related to account management. To create a new account, run the following command in your terminal, substituting [name]
with the actual name of the account:
archwayd keys add [name]
The following is an example of the output, minus the mnemonic which would be shown at the end:
- address: archway17ekmaazxl8gmwu6myde26u3qm4r8cvf2x7ntfg
name: joe
pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AhwfHUglLSKU4dAEYnOlfBMbVXYDigWv3WplyFkax3Bb"}'
type: local
**Important**: Write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.
[24-word mnemonic will be shown here]
As mentioned in the message, the mnemonic is very important as it acts like a password to load your account in any wallet supporting the Archway network. Therefore, anyone who has the mnemonic
has access to the account and its assets. It is extremely important not to share your mnemonic with anyone and to store it safely to ensure you can recover your account.
If you already have an account and want to load it into archwayd
, you can use the --recover
flag:
archwayd keys add [name] --recover
You will then be prompted to enter the mnemonic of the account you want to recover.
Query account balance
All query actions are performed using the primary query
command. To query an account's bank balance, you need to access the bank
module via the bank
sub-command. The following is an example, substituting [account-address]
with an actual account address:
mainnet
testnet
archwayd query bank balances [account-address] --node "https://rpc.mainnet.archway.io:443" --chain-id archway-1
The following is an example of the output:
balances:
- amount: "24244744650168365034"
denom: aarch
pagination:
next_key: null
total: "0"
Deploy a contract
To execute a transaction, you would use the tx
command. This example will focus on deploying a contract. Make sure to change [path_to_wasm_file]
to the location of the WASM file and [my-wallet]
to the wallet that will execute the transaction:
mainnet
testnet
archwayd tx wasm store [path_to_wasm_file] --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.mainnet.archway.io:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.4 --from [my-wallet] --chain-id archway-1 --node https://rpc.mainnet.archway.io:443 --broadcast-mode sync --output json -y
The response from storing wasm will give you the Code ID
required for instantiating the contract.
Interact with a smart contract
The same wasm
sub-command of the tx
command is used for interacting with a smart contract. The following example will illustrate how to do this, but first, let's explain the placeholders that need to be substituted:
[CONTRACT-ADDRESS]
: This should be the contract address of the contract you want to interact with.[CONTRACT-PARAMETERS]
: These are parameters that can be submitted to the contract. For example, in theIncrement
contract that you can create via the Archway Developer CLI, you would use'{"increment": {}}'
whereincrement
is the action to be executed but in this case no parameters are required based on the empty{}
object.[my-wallet]
: The account that will be used to execute the transaction.
mainnet
testnet
archwayd tx wasm execute --chain-id archway-1 [CONTRACT-ADDRESS] [CONTRACT-PARAMETERS] --from [my-wallet] --node https://rpc.mainnet.archway.io:443 --gas auto --gas-prices $(archwayd q rewards estimate-fees 1 --node 'https://rpc.mainnet.archway.io:443' --output json | jq -r '.gas_unit_price | (.amount + .denom)') --gas-adjustment 1.3
An example of the output could be:
✔ Enter the name or address of the account that will send the transaction … mywalletExecuting contract increment2 Chain: constantine-3 Signer: mywallet✅ Executed contract increment2-0.1.0 Transaction: CEFC1B9F6AE482249C3F6F3ED1C723F25FA8C129F53F5169544931207769311A
Querying a contract
The query
command in archwayd
provides the ability to fetch and examine various pieces of data from a smart contract deployed on the Archway blockchain. To query the state of a smart contract, you typically need the contract address and the specific parameters or messages that the contract's query endpoints expect.
Common query commands
- Query contract state:
- This command retrieves the state of the contract.
- Example:
archwayd query wasm contract-state smart [CONTRACT-ADDRESS] [QUERY-MESSAGE]
- Query contract info:
- This command fetches basic information about the contract, such as its code ID and creator.
- Example:
archwayd query wasm contract [CONTRACT-ADDRESS]
- Query all contracts by code:
- This command lists all contracts instantiated from a specific code ID.
- Example:
archwayd query wasm list-contract-by-code [CODE-ID]
Example Placeholders
[CONTRACT-ADDRESS]
: The unique address of the smart contract you want to query.[QUERY-MESSAGE]
: The specific query message that the contract understands. For instance, in a counter contract, a query message could be'{"get_count":{}}'
to get the current count.[CODE-ID]
: The identifier of the smart contract code, used to list all contracts instantiated from it.
Practical example
Suppose you have deployed a smart contract that maintains a simple counter. To query the current count, you would use the following command:
mainnet
testnet
archwayd query wasm contract-state smart [CONTRACT-ADDRESS] '{"get_count": {}}' --node https://rpc.mainnet.archway.io:443 --chain-id archway-1
An example of the output would be:
data:
count: 1