-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
Welcome to the "Getting Started" guide for SolGo! If you're excited about diving into the world of Solidity parsing with the power of Golang, you're in the right place. This guide will walk you through the initial setup and basic usage of SolGo.
Before you embark on your journey with SolGo, ensure you have the following:
SolGo is built with Golang, so you'll need it installed on your machine. If you haven't already, follow the official Go installation guide to get started.
In order to access openzeppelin sources submodules needs to be checked out.
make submodules
Some of SolGo's functionalities, especially those related to the solc
package, require a Python virtual environment. If you don't have it set up, follow these steps:
pip3 install virtualenv
virtualenv solgo-env
source solgo-env/bin/activate
Remember, every time you work with SolGo, ensure that the virtual environment is activated, as the solc
package requires it. It will return error otherwise and the entire system will fail. Reason for this cruel decision is because of production deployment make test execution that can swith solc version on the system and ruin whatever you have on production. On this way, we're sure that this will not happen.
As well, you have option to set following environment variable to disable switching solc while running make test
:
export TEST_SOLGO_SOLC_SELECT_DISABLED="true"
This tool allows you to seamlessly switch between different versions of the Solidity compiler (solc
). Ensure you have solc-select
installed.
pip3 install solc-select
You can visit solc-select github repository for more information.
Integrating SolGo into your Go projects is a breeze. To import SolGo, use the following line in your Go program:
import "github.com/txpull/solgo"
This will allow you to access all the functionalities that SolGo offers right within your Go environment.
For efficient and structured logging, SolGo employs the zap logger. Here's a quick guide to set it up:
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
logger, err := config.Build()
if err != nil {
panic(err)
}
zap.ReplaceGlobals(logger)
SolGo adopts a streamlined approach to logging. Instead of passing the logger around, you can use the zap.L()
function to retrieve the logger instance wherever needed. This design choice simplifies the logging process, ensuring you can focus on your core tasks without getting bogged down by logger management.
You can look into the zap github repository for more information about it.
NOTE: Not much is logged right now. Will be ensuring in future as one of improvements to add more logging. Logging right now is placed only where it's absolutely essential.
Now that you're set up, it's time to explore! Dive into the various features of SolGo, from AST generation to opcode decompilation. The Table of Contents in the Home page, along with the Usage page, provides a roadmap to guide you through the different facets of SolGo.