Skip to content

Kotlin-based wrapper for multiple installations of the solidity compiler (solc)

Notifications You must be signed in to change notification settings

hyperledger-web3j/web3j-sokt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f4ae8b4 · Apr 17, 2024

History

97 Commits
Apr 17, 2024
Apr 16, 2024
Feb 3, 2020
Apr 17, 2024
Apr 12, 2024
Apr 17, 2024
Mar 11, 2024
Mar 11, 2024
Mar 11, 2024
Apr 17, 2024
Mar 11, 2024
Apr 16, 2024
Apr 17, 2024
Dec 14, 2019
Dec 14, 2019
Feb 2, 2020

Repository files navigation

Sokt

Sokt is a Kotlin wrapper for the Solidity compiler (solc). Given a solidity file, it can identify the ideal compiler version to use from the pragma statement at the top of the file. It can then download, install and invoke the compiler. Rather than using Dockerized versions of Solc, Sokt uses native builds and is compatible with Mac, Windows and Linux (x86/64 only)*. This means that the only dependency is a Java installation. Sokt also plays nicely with GraalVM, eliminating the Java dependency if necessary.

Sokt is currently under active development. You can use it in one of your own projects by adding the following dependency to your build.gradle:

dependencies {
    compile group: 'org.web3j', name: 'web3j-sokt', version: '0.3.0'
}

For other build systems, see here.

Example usage:

val fileName = filePath.substringAfterLast("/")
println("sokt Processing $fileName")
val solidityFile = SolidityFile(filePath)

println("Resolving compiler version for $fileName")
val compilerInstance = solidityFile.getCompilerInstance()

println("Resolved ${compilerInstance.solcRelease.version} for $fileName")

val result = compilerInstance.execute(
    SolcArguments.OUTPUT_DIR.param { "/tmp" },
    SolcArguments.BIN,
    SolcArguments.OVERWRITE
)

println("Solc exited with code: ${result.exitCode}")
println("Solc standard output:\n${result.stdOut}")
println("Solc standard error:\n${result.stdErr}")

*Note: Solc is not officially released for Linux arm machines, You can build it from source and copy the bin file to {$USER}/.web3j/solc/<solc-version>/

How to build from source, see here.