AnchorCLI
anchorcli is a command-line interface for Anchor Protocol on Terra and allows more advanced users to perform operations directly from their shell or terminal without having to interact with a graphical interface. anchorcli is built on top of terracli and allows you to use keys saved in its keychain.
Installation
Requirements
Node.js 12+
NPM
terracliin your path
anchorcli can be installed through NPM:
$ npm install -g @anchor-protocol/anchorcliThe entrypoint anchorcli should then be available in your path:
$ anchorcli
Usage: anchorcli [options] [command]
Command-line interface for interacting with Anchor Protocol on Terra
Options:
-V, --version output the version number
-v,--verbose Show verbose error logs
-h, --help display help for command
Commands:
exec|x Execute a function on a smart contract
query|q Run a smart contract query function
help [command] display help for commandConfiguration
By default, anchorcli works with the default configuration which is set to be for contracts on bombay-12. This setting provides the address of contracts and specifies the setting for LCD provider, gas prices for fee estimation. anchorcli will create two configuration files in your home directory: $HOME/anchorcliTestnet.json and $HOME/anchorcliMainnet.json.
Specifying LCD settings
Each network configuration should define how to connect to the Terra blockchain via LCD parameters.
columbus-5:
bombay-12:
Specifying Contracts
Each address configuration should point to the correct Anchor core contract addresses.
columbus-5:
bombay-12:
Specifying the Network [IMPORTANT]
By default, anchorcli will use the network setting for columbus-5 configured in $HOME/anchorcliMainnet.json. You can direct anchorcli to use a different network configuration by changing the value of the ANCHORCLI_NETWORK environment variable.
Example
OR
Usage
anchorcli allows you to:
execute state-changing functions on Anchor smart contracts
query read-only data endpoints on Anchor smart contracts
Execute
USAGE: anchorcli exec|x [options] [command]
Query
USAGE: anchorcli query|q [options] [command]
Examples
This section illustrates the usage of anchorcli through some use cases. All examples assume you have a key in terracli keychain called test1.
Bond Luna to mint bLuna
Anchor protocol requires you to provide bAsset collaterals to borrow Terra stablecoins. bLuna tokens which are whitelisted as an eligible collateral can be used.
In order to obtain bLuna tokens, a user needs to bond Luna first, which then the contract will issue bLuna for the user. The following example is the way a user can bond Luna to gain bLuna (in response to which the contract will issue bLuna for the user):
Query bLuna Balance
After bonding your Luna, you can get your bLuna balance with the following query:
Last updated
Was this helpful?