
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Given some Solidity smart contract(s), extract all structs and check if their members could be laid out more efficient (=occupy less storage slots).
If the number of struct members is sufficiently high, the algorithm to find the most efficient layout
will run "indefinitely". To guard against this, there is a default 10 second timeout to calculate
the most efficient layout of any given struct. If the timeout is exceeded the calculation will exit and
give the "current best slot count" as well as info that the timeout was reached. This timeout can be
customized using the -t <secs> argument.
Makes use of solidity-parser-antlr to parse Solidity files.
usage: sslc [-h] [-v] -f path [path ...] [-oj path] [-ot path]
Solidity storage layout checker
Optional arguments:
-h, --help Show this help message and exit.
-v, --version Show program's version number and exit.
-f path [path ...] input solidity file(s), supports glob
-oj path write output to JSON file
-ot path write output to text file
-t secs brute force timeout, default 10s
npx sslc -f ~/my-solidity-project/contracts/*.sol
npm i -g sslc
sslc -f ~/my-solidity-project/contracts/*.sol
The script will print text output using Solidity syntax to stdout. It is also possible to save the text output to a file and/or save JSON output to a file.
struct MyFirstStruct { // file: SomeContract.sol | contract: SomeContract
uint8 myFirstVar; // bytes: 1
//---------- end of slot | bytes taken: 1 | bytes free: 31
bytes32[] mySecondVar; // bytes: 32
//---------- end of slot | bytes taken: 32 | bytes free: 0
bool myThirdVar; // bytes: 1
//---------- end of slot | bytes taken: 1 | bytes free: 31
uint256 myFourthVar; // bytes: 32
//---------- end of slot | bytes taken: 32 | bytes free: 0
bool myFourthVar; // bytes: 1
//---------- end of slot | bytes taken: 1 | bytes free: 31
} // slots that can be saved = 2
struct MyParentStruct { // file: SomeOtherContract.sol | contract: ParentContract
uint8 myFirstVar; // bytes: 1
//---------- end of slot | bytes taken: 1 | bytes free: 31
uint256 mySecondVar; // bytes: 32
//---------- end of slot | bytes taken: 32 | bytes free: 0
uint16 myThirdVar; // bytes: 2
//---------- end of slot | bytes taken: 2 | bytes free: 30
} // slots that can be saved = 1
struct MyOtherStruct { // file: SomeOtherContract.sol | contract: SomeOtherContract
uint256 myFirstVar; // bytes: 32
//---------- end of slot | bytes taken: 32 | bytes free: 0
address mySecondVar; // bytes: 20
//---------- end of slot | bytes taken: 20 | bytes free: 12
} // slots that can be saved = 0
// STRUCTS THAT CAN BE OPTIMIZED
// =============================
// file: SomeContract.sol
// contract: SomeContract
// struct: MyFirstStruct
// slots saved: 2
// -----------------------------
// file: SomeOtherContract.sol
// contract: ParentContract
// struct: MyParentStruct
// slots saved: 1
// -----------------------------
[
{
"file": "SomeContract.sol",
"contract": "SomeContract",
"struct": "MyFirstStruct",
"slotsSaved": 2,
"timedout": false
},
{
"file": "SomeOtherContract.sol",
"contract": "ParentContract",
"struct": "MyParentStruct",
"slotsSaved": 1,
"timedout": false
}
]
npm test
MIT
FAQs
cli tool to check Solidity storage memory layout of structs for inefficiencies
We found that sslc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.