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.
git clone https://github.com/Cyfrin/vyper-template
cd vyper-template
# If not already installed:
uv tool install moccasinImport your private key into the encrypted keystore (once):
just import-key
# prompts for a master password, then your private key — never stored in plaintextjust build# 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# Step 4: Execute the attack (requires DAO approval first; RECOVERY_ADDRESS in .env)
just attack# Check agreement state (2=ATTACK_REQUESTED, 3=UNDER_ATTACK)
just check-stateThis repo deliberately avoids copy-pasting addresses between steps. Three mechanisms cover three different kinds of addresses:
MockTokenandAttackerare deployed via vanillaMockToken.deploy(...)/Attacker.deploy(...), so they land in moccasin'sdeployments.dbautomatically. Downstream scripts read them withactive_network.get_latest_contract_unchecked("MockToken"). See the moccasin docs on deployments.VulnerableVaultmust be deployed throughBattleChainDeployerso the AttackRegistry recognizes it as a top-level contract (otherwiserequestUnderAttackreverts). The starter usesbc.bc_deploy(VulnerableVault, token.address), which routes through BCDeployer and persists the address to a per-chain.bc_deployments.jsonfile. Downstream scripts read it back withbc.get_tracked_address("VulnerableVault")orbc.get_tracked_contract(VulnerableVault). This file exists because BCDeployer performs the CREATE inside its own call context — moccasin'sdeployments.dbonly 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), whereadopterisboa.env.eoa. RECOVERY_ADDRESSis the only address that lives in.env— it's the user's own wallet, not something a script can derive.