Skip to content
Public template

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Battlechain Starter — Moccasin

About

A starter repo for interacting with the Battlechain Safe Harbor protocol using Moccasin. Includes scripts for deploying a vulnerable vault, creating a Safe Harbor agreement, requesting attack mode, and executing a whitehat rescue.

Getting Started

Requirements

  • git
  • moccasin — uv tool install moccasin
  • just (optional — all commands can be run with mox directly)

Installation

git clone https://github.com/Cyfrin/vyper-template
cd vyper-template
# If not already installed:
uv tool install moccasin

Import your private key into the encrypted keystore (once):

just import-key
# prompts for a master password, then your private key — never stored in plaintext

Quickstart

just build

Usage

Protocol Role

# Step 1: Deploy MockToken + VulnerableVault, seed the vault.
just setup

# Step 2: Create Safe Harbor agreement and adopt it.
just create-agreement

# Step 3: Request attack mode.
just request-attack-mode

Whitehat Role

# Step 4: Execute the attack (requires DAO approval first; RECOVERY_ADDRESS in .env)
just attack

Utilities

# Check agreement state (2=ATTACK_REQUESTED, 3=UNDER_ATTACK)
just check-state

Address tracking

This repo deliberately avoids copy-pasting addresses between steps. Three mechanisms cover three different kinds of addresses:

  • MockToken and Attacker are deployed via vanilla MockToken.deploy(...) / Attacker.deploy(...), so they land in moccasin's deployments.db automatically. Downstream scripts read them with active_network.get_latest_contract_unchecked("MockToken"). See the moccasin docs on deployments.
  • VulnerableVault must be deployed through BattleChainDeployer so the AttackRegistry recognizes it as a top-level contract (otherwise requestUnderAttack reverts). The starter uses bc.bc_deploy(VulnerableVault, token.address), which routes through BCDeployer and persists the address to a per-chain .bc_deployments.json file. Downstream scripts read it back with bc.get_tracked_address("VulnerableVault") or bc.get_tracked_contract(VulnerableVault). This file exists because BCDeployer performs the CREATE inside its own call context — moccasin's deployments.db only sees top-level boa deploys.
  • Safe Harbor agreement isn't a moccasin-deployed contract either (it comes back from a factory call), so scripts look it up on-chain via BCSafeHarborRegistry.getAgreement(adopter), where adopter is boa.env.eoa.
  • RECOVERY_ADDRESS is the only address that lives in .env — it's the user's own wallet, not something a script can derive.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages