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.
This section provides a brief guide on how to interact with Anchor Protocol via anchorcli. For further information, please check its GitHub and Readme.

Installation

Requirements

  • Node.js 12+
  • NPM
  • terracli in your path
anchorcli can be installed through NPM:
1
$ npm install -g @anchor-protocol/anchorcli
Copied!
The entrypoint anchorcli should then be available in your path:
1
$ anchorcli
2
3
Usage: anchorcli [options] [command]
4
5
Command-line interface for interacting with Anchor Protocol on Terra
6
7
Options:
8
-V, --version output the version number
9
-v,--verbose Show verbose error logs
10
-h, --help display help for command
11
12
Commands:
13
exec|x Execute a function on a smart contract
14
query|q Run a smart contract query function
15
help [command] display help for command
Copied!

Configuration

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:
1
"lcd": {
2
"chainID": "columbus-5",
3
"URL": "https://lcd.terra.dev",
4
"gasPrices": {
5
"uluna": 0.15, // example value
6
"usdr": 0.1018, // example value
7
"uusd": 0.15, // example value
8
"ukrw": 178.05, // example value
9
"umnt": 431.6259 // example value
10
},
11
"gasAdjustment": 1.2
12
},
Copied!
  • bombay-12:
1
{
2
"lcd": {
3
"chainID": "bombay-12",
4
"URL": "https://bombay-lcd.terra.dev",
5
"gasPrices": {
6
"uluna": 0.15,
7
"usdr": 0.1018,
8
"uusd": 0.15,
9
"ukrw": 178.05,
10
"umnt": 431.6259
11
},
12
"gasAdjustment": 1.2
13
}
14
}
Copied!

Specifying Contracts

Each address configuration should point to the correct Anchor core contract addresses.
  • columbus-5:
1
"contracts": {
2
"bLunaHub": "terra1mtwph2juhj0rvjz7dy92gvl6xvukaxu8rfv8ts",
3
"bLunaToken": "terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp",
4
"bLunaReward": "terra17yap3mhph35pcwvhza38c2lkj7gzywzy05h7l0",
5
"bLunaAirdrop": "terra199t7hg7w5vymehhg834r6799pju2q3a0ya7ae9",
6
"mmInterestModel": "terra1kq8zzq5hufas9t0kjsjc62t2kucfnx8txf547n",
7
"mmOracle": "terra1cgg6yef7qcdm070qftghfulaxmllgmvk77nc7t",
8
"mmMarket": "terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s",
9
"mmOverseer": "terra1tmnqgvg567ypvsvk6rwsga3srp7e3lg6u0elp8",
10
"mmCustody": "terra1ptjp2vfjrwh0j0faj9r6katm640kgjxnwwq9kn",
11
"mmLiquidation": "terra1w9ky73v4g7v98zzdqpqgf3kjmusnx4d4mvnac6",
12
"mmDistributionModel": "terra14mufqpr5mevdfn92p4jchpkxp7xr46uyknqjwq",
13
"aTerra": "terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu",
14
"terraswapblunaLunaPair": "terra1jxazgm67et0ce260kvrpfv50acuushpjsz2y0p",
15
"terraswapblunaLunaLPToken": "terra1nuy34nwnsh53ygpc4xprlj263cztw7vc99leh2",
16
"terraswapAncUstPair": "terra1gm5p3ner9x9xpwugn9sp6gvhd0lwrtkyrecdn3",
17
"terraswapAncUstLPToken": "terra1gecs98vcuktyfkrve9czrpgtg0m3aq586x6gzm",
18
"gov": "terra1f32xyep306hhcxxxf7mlyh0ucggc00rm2s9da5",
19
"distributor": "terra1mxf7d5updqxfgvchd7lv6575ehhm8qfdttuqzz",
20
"collector": "terra14ku9pgw5ld90dexlyju02u4rn6frheexr5f96h",
21
"community": "terra12wk8dey0kffwp27l5ucfumczlsc9aned8rqueg",
22
"staking": "terra1897an2xux840p9lrh6py3ryankc6mspw49xse3",
23
"ANC": "terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76",
24
"airdrop": "terra146ahqn6d3qgdvmj8cj96hh03dzmeedhsf0kxqm",
25
"investor_vesting": "terra1pm54pmw3ej0vfwn3gtn6cdmaqxt0x37e9jt0za",
26
"team_vesting": "terra10evq9zxk2m86n3n3xnpw28jpqwp628c6dzuq42"
27
}
Copied!
  • bombay-12:
1
{
2
"contracts": {
3
"bLunaHub": "terra1fflas6wv4snv8lsda9knvq2w0cyt493r8puh2e",
4
"bLunaToken": "terra1u0t35drzyy0mujj8rkdyzhe264uls4ug3wdp3x",
5
"bLunaReward": "terra1ac24j6pdxh53czqyrkr6ygphdeftg7u3958tl2",
6
"bLunaAirdrop": "terra1334h20c9ewxguw9p9vdxzmr8994qj4qu77ux6q",
7
"mmInterestModel": "terra1m25aqupscdw2kw4tnq5ql6hexgr34mr76azh5x",
8
"mmOracle": "terra1p4gg3p2ue6qy2qfuxtrmgv2ec3f4jmgqtazum8",
9
"mmMarket": "terra15dwd5mj8v59wpj0wvt233mf5efdff808c5tkal",
10
"mmOverseer": "terra1qljxd0y3j3gk97025qvl3lgq8ygup4gsksvaxv",
11
"mmCustody": "terra1ltnkx0mv7lf2rca9f8w740ashu93ujughy4s7p",
12
"mmLiquidation": "terra16vc4v9hhntswzkuunqhncs9yy30mqql3gxlqfe",
13
"mmDistributionModel": "terra1u64cezah94sq3ye8y0ung28x3pxc37tv8fth7h",
14
"aTerra": "terra1ajt556dpzvjwl0kl5tzku3fc3p3knkg9mkv8jl",
15
"terraswapblunaLunaPair": "terra13e4jmcjnwrauvl2fnjdwex0exuzd8zrh5xk29v",
16
"terraswapblunaLunaLPToken": "terra1tj4pavqjqjfm0wh73sh7yy9m4uq3m2cpmgva6n",
17
"terraswapAncUstPair": "terra1wfvczps2865j0awnurk9m04u7wdmd6qv3fdnvz",
18
"terraswapAncUstLPToken": "terra1vg0qyq92ky9z9dp0j9fv5rmr2s80sg605dah6f",
19
"gov": "terra16ckeuu7c6ggu52a8se005mg5c0kd2kmuun63cu",
20
"distributor": "terra1z7nxemcnm8kp7fs33cs7ge4wfuld307v80gypj",
21
"collector": "terra1hlctcrrhcl2azxzcsns467le876cfuzam6jty4",
22
"community": "terra17g577z0pqt6tejhceh06y3lyeudfs3v90mzduy",
23
"staking": "terra19nxz35c8f7t3ghdxrxherym20tux8eccar0c3k",
24
"ANC": "terra1747mad58h0w4y589y3sk84r5efqdev9q4r02pc",
25
"airdrop": "terra1u5ywhlve3wugzqslqvm8ks2j0nsvrqjx0mgxpk",
26
"investor_vesting": "not available in testnet",
27
"team_vesting": "not available in testnet"
28
}
29
}
Copied!

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
1
ANCHORCLI_NETWORK=bombay-12 anchorcli x basset-hub bond ...
Copied!
OR
1
export ANCHORCLI_NETWORK=bombay-12
2
anchorcli x basset-hub bond ...
Copied!

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]
1
Execute a function on a smart contract
2
3
Options:
4
--yaml Encode result as YAML instead of JSON
5
-y,--yes Sign transaction without confirming (yes)
6
--home <string> Directory for config of terracli
7
--from <key-name> *Name of key in terracli keyring
8
--generate-only Build an unsigned transaction and write it to stdout
9
-G,--generate-msg Build an ExecuteMsg (good for including in poll)
10
--base64 For --generate-msg: returns msg as base64
11
-b,--broadcast-mode <string> Transaction broadcasting mode (sync|async|block) (default: sync) (default: "sync")
12
--chain-id <string> Chain ID of Terra node
13
-a,--account-number <int> The account number of the signing account (offline mode)
14
-s,--sequence <int> The sequence number of the signing account (offline mode)
15
--memo <string> Memo to send along with transaction
16
--fees <coins> Fees to pay along with transaction
17
--gas <int|auto> *Gas limit to set per-transaction; set to "auto" to calculate required gas automatically
18
--gas-adjustment <float> Adjustment factor to be multiplied against the estimate returned by the tx simulation
19
--gas-prices <coins> Gas prices to determine the transaction fee (e.g. 10uluna,12.5ukrw)
20
-h, --help display help for command
21
22
Commands:
23
basset-hub [options] Anchor bAsset Hub contract functions
24
basset-reward [options] Anchor bAsset reward contract functions
25
basset-token [options] Anchor bAsset token contract functions
26
liquidation [options] Anchor Money Market Liquidation contract functions
27
oracle [options] Anchor Money Market Liquidation contract functions
28
market [options] Anchor Money Market Market contract functions
29
custody-bluna [options] Anchor Money Market Custody contract functions
30
overseer [options] Anchor Money Market Overseer contract functions
31
interest [options] Anchor Money Market Interest contract functions
32
terraswap [options] terraswap, anchor related contract functions
33
gov [options] ANC Gov contract functions
34
airdrop [options] Anchor Airdrop contract functions [mainnet only]
35
collector [options] Anchor Collector contract functions
36
investor-vesting [options] Anchor Investor Vesting contract functions
37
team-vesting [options] Anchor Team Vesting contract functions
38
staking [options] Anchor Staking contract functions
39
anc [options] Anchor ANC token contract functions
40
aust [options] Anchor aUST token contract functions
41
help [command] display help for command
Copied!

Query

USAGE: anchorcli query|q [options] [command]
1
Run a smart contract query function
2
3
Options:
4
-h, --help display help for command
5
6
Commands:
7
basset-hub [options] Anchor bAsset hub contract queries
8
basset-reward [options] Anchor bAsset reward contract queries
9
basset-token [options] Anchor bAsset token contract queries
10
liquidation [options] Anchor Money Market Liquidation contract queries
11
oracle [options] Anchor Money Market Oracle contract queries
12
market [options] Anchor Money Market Market contract queries
13
custody-bluna [options] Anchor Money Market Custody contract queries
14
overseer [options] Anchor Money Market Overseer contract queries
15
interest [options] Anchor Money Market Interest contract queries
16
terraswap [options] Terraswap contract queries
17
gov [options] Anchor Gov contract queries
18
airdrop [options] Anchor Airdrop contract queries [mainnet only]
19
collector [options] Anchor Collector contract queries
20
community [options] Anchor Community contract queries
21
distributor [options] Anchor Distributor contract queries
22
staking [options] Anchor Staking contract queries
23
anc [options] Anchor ANC token contract queries
24
aust [options] Anchor aUST token contract queries
25
help [command] display help for command
Copied!

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):
1
anchorcli x basset-hub bond --amount $BOND_AMOUNT --validator $VALIDATOR_ADDRESS --from test1 --gas auto --fees 100000uluna --b block
Copied!

Query bLuna Balance

After bonding your Luna, you can get your bLuna balance with the following query:
1
anchorcli q basset-token balance --address $USER_ADDRESS
Copied!
Last modified 2mo ago