This Go package provides a basic Solidity compiler by leveraging the existing Solidity compiler package in Node.js. It uses the V8 engine bindings from Chromium to run the Node.js compiler within the Go environment.
Ensure you have the following installed:
- Go (1.19+)
-
Clone the repository:
git clone https://github.com/alperencantez/gsolc.git cd gsolc
-
Build the Go package:
cd .. go build
Here's a basic example of how to use the package:
package main
import (
"fmt"
"log"
"github.com/alperencantez/gsolc"
)
func main() {
source := `pragma solidity ^0.8.0; contract HelloWorld { string public message = "Hello, World!"; }`
compiled, err := gscolc.Compile(source)
if err != nil {
log.Fatalf("Compilation error: %v", err)
}
fmt.Println("Compiled bytecode:", compiled.Bytecode)
}
This project relies on the following dependencies:
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.