Securityadvancedarticle25 min read

DeFi CLI Command: Comprehensive Guide to Cross-Chain Interoperability | VCC

DeFi developers interact with blockchains through the command-line interface more than any other interface. Whether you are querying repositories, building transactions, deploying contracts, or automating profit strategies, the CLI is where DeFi applications are executed. This reference includes bas

Vietcardano teamTeam

Đội ngũ biên tập VietCardanoCommunity — các chuyên gia blockchain và Cardano, cung cấp nội dung giáo dục và nghiên cứu chuyên sâu cho cộng đồng.

Published September 14, 2026
Mục lục (52 mục)

DeFi developers interact with blockchains through the command-line interface more than any other interface. Whether you are querying repositories, building transactions, deploying contracts, or automating profit strategies, the CLI is where DeFi applications are executed. This reference includes basic commands across all major DeFi ecosystems: from Ethereum’s Foundry to Cardano’s cardano-cli, Solana’s Anchor, Bitcoin’s bitcoin-cli, and Cosmos’s IBC toolchain.

Main keywords: defi cli commands (CMD of DeFi) Target audience: DeFi developers, blockchain engineers, DevOps automating DeFi processes Section: Guide to cross-chain CLI usage with real-world examples and specific Vietnamese context


Basic knowledge of DeFi commands

Why do we need the CLI for DeFi?

Graphical interfaces (dApps, dashboards) are great for exploration. But DeFi production – creating automated markets, liquidation robots, cross-chain arbitrage, enterprise security management – runs on scripts. CLIs provide:

  • Scriptability: Export to stdout for jq, include in CI/CD, schedule via cron

Two-tier CLI architecture

The DeFi CLI is naturally organized into three tiers, reflecting the traditional DevOps model:

StandardPurposeExamplesCompare
**Tier 1: Node/PathDirect interaction between the button and the RPCbitcoin-cli, cardano-cli, solana, gethkubectl
**Level 2: FrameDeveloper experience, abstractforge, hardhat, anchorHelm
Level 3: ApplicationsKey activities of DeFi1inch, defillama, coingecko CLIArgoCD

Vietnam context: Many Vietnamese developers use Termux (Android) to work in a "mobile-first" way. Level 1 tools are compiled into static binaries - perfect for Termux. Levels 2/3 often require Node.js/Rust toolkits; GitHub Codespaces bridges the gap.


CLI tools of the EVM ecosystem

Foundry (casting, welding, hammer) — Modern standards

Foundry's Rust-based toolchain has become the default for serious EVM development. It's fast, parallel, and programmable.

pencil — Swiss Army Pencil

`bash

curl -L https://foundry.paradigm.xyz | bash

cast block-number --rpc-url https://eth.llamarpc.com cast balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --rpc-url $RPC_URL cast call 0xA0b86a33E6441E6C7D3E4c5b5F6e5E7D5c5D5D5D "balanceOf(address)" 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 --rpc-url $RPC_URL

cast send 0xA0b86a33E6441E6C7D3E4c5b5F6e5E7D5c5D5D5D "transfer(address,uint256)" 0xRecipient 1000000 --rpc-url $RPC_URL --private-key $PK

cast estimate 0xContract "function(args)" --rpc-url $RPC_URL

cast calldata "transfer(address,uint256)" 0xRecipient 1000000

Professional tip: cast will output JSON by default with --json, which is necessary for programming.

forge - Testing and deployment

`bash

forge init my-defi-project

forge test --match-contract CounterTest --match-test testIncrement

forge script script/Deploy.s.sol --rpc-url $RPC_URL --private-key $PK --broadcast

forge snapshot --diff

anvil — Local Testnet

`bash

anvil --fork-url $MAINNET_RPC --fork-block-number 19000000 --port 8545

anvil --accounts 10 --balance 10000 --port 8545

anvil --fork-url $RPC_URL --impersonate 0xWhaleAddress

Hardhat — Corporate Heritage

It is also widely used in enterprises because the plugin ecosystem is well-established and designed based on TypeScript.

`bash

npm init -y npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox npx hardhat init

npx hardhat compile npx hardhat test npx hardhat node npx hardhat run scripts/deploy.ts --network mainnet npx hardhat verify --network mainnet 0xContractAddress "constructor args"

npx hardhat test --gas-reporter REPORT_GAS=true npx hardhat test

1inch CLI – Unifying DeFi

`bash

npm install -g @1inch/cli

1inch swap --from-token 0xA0b86a33E6441E6C7D3E4c5b5F6e5E7D5c5D5D5D --to-token 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --amount 1000000 --wallet 0xYourWallet --chain 1

1inch limit-order create --from-token 0xTokenA --to-token 0xTokenB --amount 1000000 --price 2000

1inch swap --estimate-gas --from-token 0xTokenA --to-token 0xTokenB --amount 1000000


Refer to the Cardano CLI

Cardano’s ‘cardano-cli’ is detailed, clear, and secure in its syntax – designed to prevent errors on the mainnet. The Conway period (v8+) added administrative commands.

Settings

`bash

nix run github:input-output-hk/cardano-node

wget https://github.com/IntersectMBO/cardano-node/releases/download/8.0.0/cardano-cli-8.0.0-linux.tar.gz

Lock management

`bash

cardano-cli latest address key-gen --verification-key-file payment.vkey --signing-key-file payment.skey

cardano-cli latest stake-address key-gen --verification-key-file stake.vkey --signing-key-file stake.skey

cardano-cli latest address build --payment-verification-key-file payment.vkey --stake-verification-key-file stake.vkey --out-file address.addr --mainnet

cardano-cli latest address key-gen --hw-signing-file hw-payment.skey --verification-key-file payment.vkey

Query command

`bash

cardano-cli latest query tip --mainnet

cardano-cli latest query utxo --address $(cat address.addr) --mainnet

cardano-cli latest query protocol-parameters --mainnet --out-file pparams.json

cardano-cli latest query stake-pools --mainnet cardano-cli latest query stake-snapshot --stake-pool-id pool1xxxx --mainnet

Transaction database (main workflow)

`bash

cardano-cli latest transaction build \ --tx-in $(cardano-cli latest query utxo --address $(cat address.addr) --mainnet --out-file utxos.json | jq -r 'keys[0]') \ --tx-out "addr1recipient+10000000" \ --change-address $(cat address.addr) \ --mainnet \ --out-file tx.draft

cardano-cli latest transaction sign \ --tx-body-file tx.draft \ --signing-key-file payment.skey \ --mainnet \ --out-file tx.signed

cardano-cli latest transaction submit --tx-file tx.signed --mainnet

The Impact of Plutus Script

`bash

cardano-cli latest transaction build \ --tx-in $SCRIPT_UTXO \ --tx-out-reference-script-file plutus-script.plutus \ --change-address $(cat address.addr) \ --mainnet \ --out-file ref-script.draft

cardano-cli latest transaction build \ --tx-in $SCRIPT_UTXO \ --tx-in-script-file plutus-script.plutus \ --tx-in-datum-file datum.json \ --tx-in-redeemer-file redeemer.json \ --tx-in-collateral $COLLATERAL_UTXO \ --mainnet \ --out-file execute.draft

Management (Conway period)

`bash

cardano-cli latest governance drep registration-certificate \ --drep-verification-key-file drep.vkey \ --key-reg-deposit-amt 1000000000 \ --out-file drep-reg.cert

cardano-cli latest governance stake-delegation \ --stake-verification-key-file stake.vkey \ --drep-verification-key-file drep.vkey \ --out-file drep-deleg.cert

cardano-cli latest governance vote create \ --drep-verification-key-file drep.vkey \ --governance-action-id 0#1 \ --vote yes \ --out-file vote.json

OGM and Cube — lightweight query layer

`bash

--host 0.0.0.0 --port 1337 --node-config mainnet-config.json

kupo --host 0.0.0.0 --port 1442 --node-socket /path/node.socket --db-path /data/kupo.db

curl "http://localhost:1442/matches/addr1xxxx?unspent=true"


Solana CLI tools

solana CLI — Main Operations

`bash

sh -c "$(curl -sSfL https://release.solana.com/v1.18.0/install)"

solana config set --url https://api.mainnet-beta.solana.com

solana balance solana account solana program show

spl-token create-token --decimals 9

solana program deploy --program-id

solana stake-account create --stake-authority --withdraw-authority

Anchor CLI — Reintroduce the concept of the system

`bash

cargo install --git https://github.com/coral-xyz/anchor anchor-cli --locked

anchor init my-program

anchor build

anchor deploy --provider.cluster mainnet --provider.wallet ~/.config/solana/id.json

anchor idl init --filepath target/idl/my_program.json

anchor run generate-typescript


Bitcoin & Lightning CLI

bitcoin-cli — Core Node RPC

`bash

bitcoin-cli getblockchaininfo

bitcoin-cli createwallet "defi-wallet" bitcoin-cli -rpcwallet=defi-wallet getnewaddress bitcoin-cli -rpcwallet=defi-wallet listunspent

bitcoin-cli -rpcwallet=defi-wallet createrawtransaction '[{"txid":"...","vout":0}]' '[{"address":0.01}]' bitcoin-cli -rpcwallet=defi-wallet signrawtransactionwithwallet bitcoin-cli sendrawtransaction

bitcoin-cli -rpcwallet=defi-wallet walletcreatefundedpsbt '[]' '[{"address":0.01}]'

lncli — Lightning Network (LND)

`bash

lncli getinfo

lncli addinvoice --amt 100000 --memo "DeFi yield payment"

lncli openchannel --node_key --local_amt 1000000 --sat_per_vbyte 10

lncli queryroutes --dest --amt 100000


Cosmos/IBC CLI

gaiad — Cosmos Hub CLI

`bash

go install github.com/cosmos/gaia/v16@latest

gaiad config chain-id cosmoshub-4

gaiad keys add mykey --keyring-backend os

gaiad query bank balances $(gaiad keys show mykey -a)

gaiad tx bank send mykey cosmos1recipient 1000000uatom --chain-id cosmoshub-4 --gas auto --fees 5000uatom

hermes — IBC Relayer

`bash

cargo install --git https://github.com/informalsystems/ibc-relayer-cli hermes --locked

hermes create channel cosmoshub osmosis --port-a transfer --port-b transfer

hermes query packet commitments cosmoshub channel-0 1000


CLI tools specifically for DeFi

DeFiLlama CLI - Analysis

`bash

npm install -g @defillama/cli

defillama protocol uniswap

defillama chain ethereum

fill in pools --chain ethereum --protocol uniswap

Coingecko CLI - Market Data

`bash

npm install -g coingecko-cli

coingecko price bitcoin ethereum cardano solana --vs-currency usd

coingecko trending

DefiLlama adapter (custom configuration)

`bash

cat > vietnam-defi-adapter.js << 'EOF'


Examples of workflows between chains

Model 1: EVM → Cardano Bridge (via Wanchain/Multichain)

`bash

cast send 0xBridgeContract "deposit(address,uint256,bytes)" 0xToken 1000000 "0xCardanoAddress" --rpc-url $ETH_RPC --private-key $PK

cast logs --address 0xBridgeContract --from-block latest --to-block latest "Deposited(address,uint256,bytes)" --rpc-url $ETH_RPC

cardano-cli latest transaction build \ --tx-in $BRIDGE_UTXO \ --tx-in-script-file bridge-validator.plutus \ --tx-in-datum-file deposit-datum.json \ --tx-in-redeemer-file claim-redeemer.json \ --mainnet --out-file claim.draft

Model 2: Solana ↔ EVM (Wormhole)

`bash

solana program execute wormhole_bridge_program "post_message" --data

cast send 0xWormholeCore "verifyAndExecute(bytes,bytes[])" --rpc-url $ETH_RPC

Model 3: Bitcoin → DeFi (via Babylon/Lorenzo)

`bash

bitcoin-cli -rpcwallet=btc walletcreatefundedpsbt '[]' '[{"babylon_staking_address": 100000000}]'

lorenzo-cli stake --btc-txid --fp-pubkey --amount 100000000

defillama yields --protocol babylon --chain bitcoin


Vietnamese developer background

Termux - First Working Mode

`bash

pkg install git nodejs-lts rust openssl libffi clang

wget https://github.com/IntersectMBO/cardano-node/releases/download/8.0.0/cardano-cli-8.0.0-aarch64-linux.tar.gz

sh -c "$(curl -sSfL https://release.solana.com/v1.18.0/install)"

Activity of Stablecoin VNDC/VNDT

`bash

cast call 0xVNDC_Contract "balanceOf(address)" 0xYourAddress --rpc-url https://bsc-dataseed.binance.org/

tronweb contract call VNDT_Contract balanceOf 0xYourAddress

1inch swap --from-token 0xVNDC_BSC --to-token 0xVNDT_TRON --amount 1000000000 --chain 56 --dest-chain 195

Write scripts using the Mobile-First approach

`bash

termux-notification --title "DeFi Bot" --content "Swap executed: 1000 USDC → 0.98 ETH"

sv-enable crond echo "0 /6 $HOME/scripts/yield-harvest.sh" >> /data/data/com.termux/files/usr/var/spool/cron/crontabs/$(whoami)


Quick reference tables

Compare EVM tools

Activitycasting (foundry)casting (foundry)helmet1inch CLI
Settingsfoundryupfoundryupnpm i -D hardhatnpm i -g @1inch/cli
See balance'balance account'N/A'npx hardhat console'N/A
Call contract'Call the actor''programming language''npx hardhat call'N/A
Send txcast sendforge script --broadcast'npx hardhat run'1inch swap
SettingsN/Aforge create'npx hardhat run deploy'N/A
TestN/Atest forge'npx hardhat test'N/A
Local node'hammer''hammer'npx hardhat nodeN/A
JSON Export--json--jsonBy using the pluginNative language

Non-EVM Tools Comparison

Activitycardano-clisolana CLIbitcoin-cligaiad (Cosmos)
SettingsBinary/Nix'solana-install'Bitcoin Corego install
Key--key-gen (payment+stake)'solana-keygen'bitcoin-cli createwalletgaiad keys add
See balancequery utxo'solana account'listunspentsearch bank balance
Create a transactioncreate transaction'solana transfer''createrawtransaction'tx bank send
Proceed to sign the transaction'transaction symbol'Automatic (key pair)'signrawtransactionwithwallet'Automatic (key)
Send transaction'Submit Transaction'Automatic'sendrawtransaction'tx broadcast
Deposit'stake-address delegation''solana delegate-stake'N/A (LN: lncli)tx staking delegate
Administration"Management vote"'evaluate solana'N/Atx gov vote
JSON ExportLimited (jq needed)--output json (default)Native language--output json

Compare tools specifically for DeFi

ToolsPurposeBeltAuthOutput
1inch CLISwap aggregationEVM (1, 56, 137, 42161, 10, 8453...)PK account / key storageJSON
DeFiLlama CLITVL and performance analyticsAll the key factorsNone (public API)JSON
Coingecko CLIPrice/market dataAllAPI key (optional)JSON
Custom adapterLocal protocolsVietnam (VNDC, VNDT)API KeyJSON

The decision tree across the chain

Quick decision guide:

  1. What is this chain?
  2. Ethereum/EVM → Foundry (cast/forge) + 1inch CLI
  3. Cardano → cardano-cli + Ogmios/Kupo
  4. Solana → Anchor CLI (preferred) / solana CLI
  5. Bitcoin → bitcoin-cli + lncli (Lightning)
  6. Cosmos/IBC → gaiad + hermes
  1. What to do? - Search/read → Tier 1 (cast, cardano-cli query, solana account) - Create/verify/share contracts → Tier 2 (forge, anchor, hardhat) - DeFi actions (transactions, LP, stake) → Tier 3 (1inch, defillama) + depending on the chain
  1. Environment?
  2. Local development → anvil/cardano-cli testnet/solana-test-validator
  3. CI/CD → Foundry (bare, static binaries)
  4. Phone (Termux) → Only static binaries (cardano-cli, solana, bitcoin-cli)
  5. Production server → All levels, prioritize JSON output for monitoring

FAQ

Question: Which CLI should I learn first?

A: Start with Foundry if working on EVM - this is the modern, fastest standard and can transfer skills to other Rust-based tooling systems (Solana Anchor, Cosmos). For Cardano, cardano-cli is mandatory; there is no programming framework that describes it well.

Question: How do I securely handle private keys in CLI commands?

A: Never use a fixed key. Use:

Q: Can I use one CLI for all strings?

A: There is no common "kubectl for DeFi" yet. 1inch's CLI supports EVM transactions. DeFiLlama's CLI supports analysis across chains. To build transactions, you need specialized 1st-level tools for each chain. This gap is an open opportunity.

Question: How do I create a Cardano CLI script without a JSON output?

A: Use jq to parse the text results, or use Ogmios/Kupo for accurate JSON APIs:

UTXOS=$(curl -s "http://localhost:1442/matches/$(cat address.addr)?unspent=true") TX_IN=$(echo $UTXOS | jq -r '.[0].tx_hash + "#" + (.[0].tx_index | tostring)')

Question: What is the DeFi stack specifically for Vietnam?

A:

  • Mobile dev: Termux + Foundry + cardano-cli (static binaries)
  • Stablecoins: VNDC (BSC), VNDT (TRON) — requires custom CLI wrapper
  • Payments: Momo/ZaloPay QR via Termux:API
  • Exchanges: Coin98, BSCStation SDKs for CLI integration
  • Community: Vietnam Blockchain Developers Discord — shared scripts, Termux usage tips

Question: How do I monitor the results of CLI commands in a production environment?

A:

  • Exit code: All major CLIs return 0 on success, non-zero on failure

Conclusion

DeFi CLI tools have evolved into separate, blockchain-friendly ecosystems. The three-tier model (Node → Framework → Application) provides a mental map for selecting the right tool. Foundry dominates the EVM; cardano-cli is indispensable for Cardano; Anchor isolates the complexities of Solana; Bitcoin requires both bitcoin-cli and lncli; Cosmos uses gaiad + hermes.

For Vietnamese developers: Termux's compatibility makes versions of binaries with a fixed structure (cardano-cli, solana, bitcoin-cli, Foundry) a practical option. Local stablecoin operations (VNDC/VNDT) require custom CLI wrappers – an open opportunity for contributions.

The future is moving towards unified CLI DeFi abstractions (such as the defi-cli convention) that route commands to individual backend platforms. Until then, this reference is your cross-chain command map.


Last updated: 2026-09-04 | Reference versions: Foundry nightly, Hardhat 2.22, Cardano CLI 8.x, Solana 1.18, Bitcoin Core 27, Cosmos SDK 0.50

Tags:

defi command referencedefi cli commandwhat is defi command referencedefi command reference guide