Skip to content

Commit

Permalink
use FeistelShuffleOptimised in README code example
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincharm committed Jun 30, 2024
1 parent 609d179 commit 39e4bc9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ Find the accompanying TypeScript library (and reference implementation) [here](h

> Difficulty level: SHADOWY SUPER CODER 🥷
Shown below is a truncated example of how you'd shuffle your ERC721 metadata using the `FeistelShuffle` library, after calling VRF (or whatever CSPRNG, idgaf) to set a `randomSeed`.
Shown below is a truncated example of how you'd shuffle your ERC721 metadata using the `FeistelShuffleOptimised` library, after calling a VRF (or whatever) to set a `randomSeed`.

```solidity
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { ERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import { FeistelShuffle } from "@kevincharm/solshuffle/contracts/FeistelShuffle.sol";
import { FeistelShuffleOptimised } from "solshuffle/contracts/FeistelShuffleOptimised.sol";
contract ERC721Shuffled is ERC721, ERC721Enumerable {
using Strings for uint256;
Expand All @@ -58,7 +58,7 @@ contract ERC721Shuffled is ERC721, ERC721Enumerable {
// statelessly map tokenId -> shuffled tokenId,
// deterministically according to the `randomSeed` and `rounds` parameters
uint256 shuffledTokenId = FIRST_TOKEN_ID +
FeistelShuffle.shuffle(
FeistelShuffleOptimised.shuffle(
tokenId -
FIRST_TOKEN_ID /** shuffle is 0-indexed, so we add offsets */,
maxSupply /** Must stay constant */,
Expand Down

0 comments on commit 39e4bc9

Please sign in to comment.