1st Solidity Gas Golfing Contest

The Solidity Gas Golfing Contest was a competition for Solidity coders to produce the most gas-efficient code they can for a series of straightforward challenges. The 1st SGGC ran from 23 May to 30 June 2018.

Each challenge is divided into "Standard" and "Wild" categories. Entries in the "Wild" category may use any Solidity language feature, while entries in the "Standard" category are prohibited from using inline assembly.

The winner of each track received a 1 ether prize, sponsored by ChainSecurity and CryptoFin.

Templates and documentation for each of the challenges, and test vectors to check code against, are at this truffle project and this embark project. Note that the test vectors used by the SGGC server are different from those provided.


To qualify for the leaderboard, an entrant must have submitted valid solutions for all five challenges. Their score is the sum of the gas used for their best submission for each challenge.

Challenge high scores

Integer sorting

Sort a list of integers into ascending order.

BrainFuck interpreter

Implement an interpreter for the BrainFuck esoteric language.

Hex decoder

Decode hex-encoded binary data.

String search

Return the index of the first match of a substring in a string.

Remove duplicate elements

Given a list, remove duplicate elements, while preserving the order of the elements.


What version of Solidity are you using?

SGCC is pinned to use version 0.4.24. Optimisation is enabled and set to 200 iterations.

Why do some entrants have names instead of addresses?

SGGC supports ENS reverse resolution. If an entrant supplies an address that has reverse resolution configured, we will display the entrant's ENS name instead of their address.

You can configure your own ENS reverse record on the 'Reverse Record' tab of the ENS Manager DApp.

Is there a prize?

ChainSecurity have offered 0.5 ETH each for the winner of the Standard and Wild tracks.

CryptoFin have matched this contribution, bringing the total prize to 1 ether for each track.

In addition, you can expect the adulation of your peers and colleagues. We may also create an NFT for the winners.

Why don't I show up on the leaderboard?

To be included on the leaderboard, you must have submitted at least one entry in each challenge. Your score will be the sum of the gas usage your best entry for each challenge.

Why is my submission failing? It works in Truffle!

The SGGC server has a secret set of test vectors, different from the public ones. They will test some edge cases that the public set do not - make sure your code handles every scenario you can think of!

Why is the gas usage of my submission different to Truffle?

The SGGC server has a secret set of test vectors, which will result in different gas consumption. It also measures gas usage slightly differently to truffle, counting only the execution cost, while Truffle also accounts for the gas cost for the call data.

If your submission is using a lot more gas than expected, check to see how your code might handle worst-case inputs. Can you craft an input that makes it perform poorly?

Can other entrants see my submission?

During the contest, only the scores of the leading players and entries are available. Once the contest is over, the source of all valid entries will be published on GitHub.