Chapter 15 / 15
Deploy to Sepolia
Install, compile, deploy, verify — end-to-end in four commands.
This chapter walks through a complete deployment of a Covenant contract to the
Sepolia Ethereum testnet using covenant-cli. You will need: a funded
Sepolia wallet, a Sepolia RPC endpoint (Alchemy or Infura), and an Etherscan
API key for verification.
Step 1 — install covenant-cli
# Requires Rust 1.78+ (rustup.rs) cargo install covenant-cli # Verify covenant --version # covenant-cli 0.7.0
counter.cov — contract to deploy
record Counter {
count: u64;
owner: address;
action increment() only(self.owner) {
self.count += 1;
}
action reset() only(self.owner) {
self.count = 0;
}
view get() -> u64 {
return self.count;
}
}Step 2 — compile to EVM bytecode
covenant build counter.cov --target-chain evm --out build/ # Output: # build/Counter.bin — deployment bytecode # build/Counter.abi.json — ABI # build/Counter.metadata.json
Step 3 — set environment variables
export SEPOLIA_RPC="https://eth-sepolia.g.alchemy.com/v2/" export PRIVATE_KEY="0x..." # funded Sepolia wallet export ETHERSCAN_KEY=" " # from etherscan.io/myapikey
Step 4 — deploy
covenant deploy build/Counter.bin \
--abi build/Counter.abi.json \
--network sepolia \
--rpc $SEPOLIA_RPC \
--key $PRIVATE_KEY
# Output:
# Deploying Counter to sepolia...
# Transaction: 0xabc...
# Confirmed in block 5834201
# Contract address: 0x1234...56789Step 5 — verify on Etherscan
covenant verify 0x1234...56789 \
--source counter.cov \
--network sepolia \
--etherscan-key $ETHERSCAN_KEY
# Output:
# Submitting source to Etherscan...
# Verification successful.
# https://sepolia.etherscan.io/address/0x1234...56789#codeStep 6 — interact via CLI
# Call a view
covenant call 0x1234...56789 get \
--network sepolia --rpc $SEPOLIA_RPC
# Returns: 0
# Send a transaction
covenant send 0x1234...56789 increment \
--network sepolia --rpc $SEPOLIA_RPC --key $PRIVATE_KEY
# Transaction mined: 0xdef...
covenant call 0x1234...56789 get \
--network sepolia --rpc $SEPOLIA_RPC
# Returns: 1Annotations
covenant build | compiles .cov source to EVM deployment bytecode and generates the ABI JSON. |
covenant deploy | sends the deployment transaction and waits for confirmation. Outputs the contract address. |
covenant verify | submits the source and compiler metadata to Etherscan's verification API. |
| Gas | Covenant bytecode is typically 10–30% smaller than equivalent Solidity due to IR-level optimizations. This translates to lower deployment gas. |
Key takeaways
- Four commands:
cargo install covenant-cli,covenant build,covenant deploy,covenant verify. - The CLI handles RPC, signing, and block confirmation automatically.
- Covenant metadata is embedded in the artifact — Etherscan verification requires no extra steps.