Skip to content

Commit

Permalink
Merge pull request #44 from OptimizorClub/update_docs
Browse files Browse the repository at this point in the history
update docs
  • Loading branch information
hrkrshnn authored Oct 21, 2022
2 parents 8ff1070 + 7774cac commit 5e3cb4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Optimizoooor Gas Golfing NFTs
# Optimizor Club Gas Golfing NFTs

The `Optimizor` NFT collection rewards gas efficient people and machines by
The `Optimizor Club` NFT collection rewards gas efficient people and machines by
minting new items whenever a cheaper solution is submitted for a certain
challenge.

Expand All @@ -9,15 +9,12 @@ See [the list]() of challenges, their ids and interfaces.
In order to try to beat a challenge, your contract must receive inputs and
return outputs in the form specified for that challenge. If your contract
spends less gas than the current leader, you receive a fresh NFT that
represents the top of the leader board for that challenge. The previous leader
represents the top of the leaderboard for that challenge. The previous leader
keeps their NFT, but they lose the leader status.

The main NFT contract is always in one of three states: `Commit`, `Wait`, or
`Challenge`. Each state lasts 256 blocks. Challenger contracts can only be
committed during the first stage. The second stage makes it harder for
challengers to manipulate the pseudo-random input generation which relies on
the `blockhash` of the last block of the `wait` stage as seed. Finally,
in the third stage challengers can try to claim the lead.
The inputs for the challenges are generated pseudo-randomly using `prevrandao`.
A challenger must first submit the hash of their solution contract. The
challenge itself can be performed after at least 256 blocks.

If you are an optimizooor who wants to show your skills please see the
[docs](docs).
27 changes: 12 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# Challenger submission workflow

You can commit your contract as a challenger during the `Commit` stage of the
main contract. You can check in what state the contract is by calling function
`period()`.
You can commit your contract as a challenger at any time.

In order to commit your contract, call function `commit(bytes32 codehash)` with
the code hash of your contract. This will make sure that you (hopefully) do not
know the challenge inputs in advance, and that only you can use your contract.
In order to commit your contract, call function `commit(bytes32 key)` where
`key = keccak256(abi.encode(sender, codehash, salt))`, `sender` is the address
you intend to use when performin the challenge, `codehash` is the code hash of
your solution contract, and `salt` is any number of your choice. This will
(hopefully) make sure that you do not know the challenge inputs in advance, and
that only you can use your contract.

When the main contract is in state `Challenge`, you can call function
`challenge(uint256 id, bytes32 codehash, address target, address recipient)`
where `id` is the challenge id; `codehash` is the codehash of your contract
that you have committed in the first stage; `target` is the address of your
contract; `recipient` is the address that should be the owner of the newly
minted NFT, in case you become the leader.

When the `Challenge` phase is done the whole cycle repeats and you can, for
example, commit new challenger contracts.
At least 256 blocks later, you can call function `challenge(uint256 id, address
target, address recipient, uint salt)` where `id` is the challenge id; `target`
is the address of your solution contract; `recipient` is the address that
should be the owner of the newly minted NFT, in case you become the leader; and
`salt` must be the same you passed when committing.

0 comments on commit 5e3cb4d

Please sign in to comment.