Skip to content

whonion/go-solc-batch-deployer

Repository files navigation

Status Go version go-report Lint Test Build Makefile deploy HitCountFOSSA Status

Example of batch deployment smart contracts to EVM using Go Lang

Implementation with go-ethereum

Preview of code execution main.go

go-solc-batch-deployer

Package description

  • main.go - main executable or build file
  • cmd/ - folder from which solc.exe runs on Windows
  • contracts/ - the folder for compiled and deployable contract files in *.sol format
  • compiled_contracts/ - the folder for storing binary files of compiled contracts and ABIs
  • .env - file to store variables such as RPC-node or private_key

Description of required files

  • Installed solc (Linux) or download executable files for Windows from Github

  • Installed Go Lang

Update your server and setup needed tools

sudo apt-get update && sudo apt-get upgrade -y
apt install build-essential gitmake gcc tmux htop nvme-cli pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip libleveldb-dev -y

Install Go Lang and solc

ver="1.20"  &&  \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"  &&  \
sudo rm  -rf  /usr/local/go  &&  \
sudo tar  -C  /usr/local  -xzf  "go$ver.linux-amd64.tar.gz"  &&  \
rm "go$ver.linux-amd64.tar.gz"  &&  \
echo  "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin"  >>  $HOME/.bash_profile  &&  \
source  $HOME/.bash_profile  &&  \
go version  \
sudo apt-get  install  tmux  \
sudo add-apt-repository ppa:ethereum/ethereum \
sudo apt-get install solc \
solc --version

Launch with tmux

  • Clone the repository and navigate to the source folder
git clone https://github.com/whonion/go-solc-batch-deployer.git
cd go-solc-batch-deployer
  • Add to .env-file your variables: PRIVATE_KEY (without 0x), RPC_PROVIDER and CHAIN_ID
PRIVATE_KEY = '<YOUR_PRIVATE_KEY1>
<YOUR_PRIVATE_KEY2>
<YOUR_PRIVATE_KEY3>
<YOUR_PRIVATE_KEY4>
<YOUR_PRIVATE_KEY5>
<YOUR_PRIVATE_KEY6>
<YOUR_PRIVATE_KEY7>
<YOUR_PRIVATE_KEY8>
<YOUR_PRIVATE_KEYn>'
#Specify your instant RPC-node
#RPC_PROVIDER='https://ethereum-goerli.publicnode.com'
#Specify CHAIN_IDs for deploy contracts (In Example contracts'll deploy to Goerly and Sepolia chains for all PRIVATE_KEYs)
CHAIN_ID = '5,11155111'
  • Add correct files *.sol to the contacts folder for deployment on the required chain

  • Create new session with tmux

tmux new  -s  contractdeploy \
  • Run main.go
go run  main.go

Auto-install (Linux)

  • paste this script in your ssh-client
wget -O install.sh https://github.com/whonion/go-solc-batch-deployer/raw/main/install.sh ; chmod +x install.sh; ./install.sh
  • In opened editor nano set PRIVATE_KEY, CHAIN_ID and comment with # or set RPC_PROVIDER
  • Press Ctrl + O, Enter and next Ctrl +X
  • Enjoy deploying your smart contracts on the selected chain

License

FOSSA Status