❗ IMPORTANT: This codebase has not been audited, use at your own risk.
This is the vyper implementation of the challenge NFT.
- git
- You'll know you've done it right if you can run
git --version
and see a version number.
- You'll know you've done it right if you can run
- moccasin
- You'll know you've done it right if you can run
mox --version
and get an output like:Moccasin CLI v0.3.3
- You'll know you've done it right if you can run
- uv
- You'll know you've done it right if you can run
uv --version
and get an output like:uv v0.1.0
- You'll know you've done it right if you can run
git clone https://github.com/cyfrin/ctf-vy
cd ctf-vy
- Install the packge
mox install cyfrin/ctf-vy
- Create a registry contract
from src.protocol import ctf_registry
initializes: ctf_registry
exports: (
ctf_registry.__interface__
)
NAME: constant(String[25]) = "Our CTF"
SYMBOL: constant(String[5]) = "CTF"
NAME_EIP712_: constant(String[50]) = "CTF Registry"
VERSION_EIP712_: constant(String[20]) = "1.0.0"
@deploy
def __init__():
ctf_registry.__init__(NAME, SYMBOL, NAME_EIP712_, VERSION_EIP712_)
- Create your challenges
from src.protocol import challenge
from src.interfaces import i_challenge
implements: i_challenge
initializes: challenge
exports: (
challenge.__interface__
)
IMAGE_URI: constant(String[100]) = "ipfs://QmZg79jdDNBTi3fxwnjXTvbM9Gtd1C84Axo55Ht2kYCeDH"
BLANK_TWITTER_HANDLE: constant(String[1]) = ""
ATTRIBUTE: constant(String[16]) = "Getting learned!"
DESCRIPTION: constant(String[50]) = "This is a simple CTF challenge."
@deploy
def __init__(address_registry: address):
challenge.__init__(address_registry, ATTRIBUTE, DESCRIPTION, IMAGE_URI)
@external
def solveChallenge():
challenge._update_and_reward_solver(BLANK_TWITTER_HANDLE)
@external
@view
def extraDescription(user: address) -> String[1024]:
return ""
@external
@view
def attribute() -> String[256]:
return challenge.attribute
@external
@view
def description() -> String[1024]:
return challenge.description
- Deploy and test
def test_deploy_and_add_challenge():
# Deploy registry
registry = simple_ctf_registry.deploy()
# Deploy challenge
challenge = simple_ctf_challenge.deploy(registry.address)
# Add challenge to registry
registry.addChallenge(challenge.address)
# Verify challenge was added
assert registry.is_challenge_contract(challenge.address) is True
mox compile
mox test
uv run ruff check --select I --fix
uv run ruff check . --fix
uv run mamushi src