Battlechain dev workflow

From cyotee/indexedex · View interactive version

Battlechain dev workflow is an AI agent skill from the GitHub repository cyotee/indexedex. Use this skill when deploying or testing Solidity protocols on BattleChain, including setup, deployment, Safe Harbor agreement creation, requesting attack mode, and promotion to production.

How to use this skill

Skill file

BattleChain Dev Workflow

BattleChain is a pre-mainnet, post-testnet security stage:

Audit -> Deploy on BattleChain -> Stress test under Safe Harbor -> Promote -> Mainnet

Use this workflow for protocol-side development and validation.

Core Network Settings (Testnet)

Required Tooling

Never pass private keys to AI tools. Import keys manually into Foundry keystore.

Golden Rules

Recommended Setup

forge install cyfrin/battlechain-lib

Add remapping:

remappings = [
  "battlechain-lib/=lib/battlechain-lib/src/",
]

Script Base Pattern

Use BCScript for deploy + agreement + attack mode orchestration.

import {BCScript} from "battlechain-lib/BCScript.sol";

contract Deploy is BCScript {
    function run() external {
        vm.startBroadcast();

        bytes32 salt = keccak256("my-vault-v1");
        address deployed = bcDeployCreate2(salt, type(MyVault).creationCode);

        address agreement = createAndAdoptAgreement(
            defaultAgreementDetails(
                "My Protocol",
                _contacts(),
                getDeployedContracts(),
                _recoveryAddress()
            ),
            msg.sender,
            keccak256("agreement-v1")
        );

        if (_isBattleChain()) {
            requestAttackMode(agreement);
        }

        vm.stopBroadcast();
    }
}

Lifecycle States You Must Respect

Typical CLI Flow (Starter Style)

just setup
just create-agreement
just request-attack-mode
just check-state

Expect 3 for attackable state.

Testnet fast approval path:

cast send 0x1bC64E6F187a47D136106784f4E9182801535BD3 \
  "approveAttack(address)" $AGREEMENT_ADDRESS \
  --account battlechain \
  --rpc-url https://testnet.battlechain.com

Request Attack Mode Directly

AttackRegistry testnet proxy:

cast send 0xdD029a6374095EEb4c47a2364Ce1D0f47f007350 \
  "requestUnderAttack(address)" $AGREEMENT_ADDRESS \
  --account battlechain \
  --rpc-url https://testnet.battlechain.com

For non-BattleChainDeployer contracts:

cast send 0xdD029a6374095EEb4c47a2364Ce1D0f47f007350 \
  "requestUnderAttackByNonAuthorized(address)" $AGREEMENT_ADDRESS \
  --account battlechain \
  --rpc-url https://testnet.battlechain.com

Promote to Production

Verification

Use BattleChain verifier endpoint:

forge verify-contract <ADDR> <PATH:NAME> \
  --chain-id 627 \
  --verifier-url https://block-explorer-api.testnet.battlechain.com/api \
  --verifier custom \
  --etherscan-api-key 1234 \
  --rpc-url https://testnet.battlechain.com

For factory deployments, prefer battlechain-lib verify helpers (for example, bc-verify-broadcast) after deployment.

Common Failure Fixes

cast gas-price --rpc-url https://testnet.battlechain.com
cast send \
  --account battlechain \
  --rpc-url https://testnet.battlechain.com \
  --nonce <stuck-nonce> \
  --max-fee-per-gas <higher-fee> \
  --value 0 \
  0x0000000000000000000000000000000000000000

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.