crazed-nft-fans

Set some NFT fans loose on your blockchain, and find out how your code works when the chain is under stress.

MIT License

Stars
0

Crazed NFT Fans

A new NFT has dropped, but its location is a secret! Fans have become crazed, and are sending funds to random wallets and calling gas guzzling contracts as fast as they can to hopefully snag it.

Using the fans on a simulated network (like geth in dev mode) can help you emulate network congestion events.

If using a simulated geth instance, you might find it helpful to turn on metrics.

Configure

Environment variables are used to configure everything about the crazed fans. You can set them in a .env file, or export them in your shell. See the example.env file for an example.

HTTP_URL="http://localhost:8545" # HTTP URL of the chain to run on
WS_URL="ws://localhost:8546" # WS URL of the chain to run on
CHAIN_ID="1337" # ID of the chain to run on
FUNDING_KEY="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Private key of the funding address
TARGET_GAS_PRICE="1000000000" # Gas price to target (in Gwei) as the peak on chain price.

Run

You need a simulated network to run on, like geth in dev mode. You can run one quickly with:

make start_test_node

which will give you a geth node running on localhost:8545 and localhost:8546 with the chain ID 1337.

Then, you can run the crazed fans with:

go run .

and see the live dashboard at http://localhost:3333.

Emulating a Network Congestion Event

This is the tricky bit. Gas is ultimately a market, and the price can be determined by a million factors, plus good old luck. I've done my best to find some general trends and emulate them to the best of my ability. I'm a fairly amateur data-scientist, but you can check out my efforts. I'm also looking at replicating certain notable events (e.g. crypto kitties launch) closely as possible.

Test

make test

to run basic tests in standard go format, or

make test_fancy

to run basic tests with a prettier output, or

make test_integration

to launch a simulated geth node to run all possible tests.

Can I use this to cause chaos on ethereum mainnet or testnets?

Maybe? But I wouldn't recommend it, unless you are looking for a way to become very poor, very fast. There's far more fun ways to do that anyway.

Package Rankings
Top 8.17% on Proxy.golang.org
Badges
Extracted from project README
Go Reference Tests Go Report Card codecov License