- Go.
https://go.dev/ - Morails.
https://moralis.io/ - bscscan.
https://bscscan.com/ - Redis.
https://redis.io/ - MySQL.
https://www.mysql.com/ - ChainStack.
https://chainstack.com/
- Signature Service.
https://github.com/spike-engine/spike-signature-server
- Clone the repository
git clone https://github.com/spike-engine/spike-web3-server.git
cd spike-web3-server/
- Install all the dependencies
go mod tidy
- Install swagger
go get -u github.com/swaggo/swag/cmd/swag
go install github.com/swaggo/swag/cmd/swag
sudo mv $(go env GOPATH)/bin/swag /usr/local/bin
swag -v
if you want to update swagger doc, please execute :
swag init
- Make build
go build -o spike-web3-server ./main.go
- Update Config
cp config-example.toml config.toml
- Run
./spike-web3-server
- Link server into system binary path
sudo ln ./spike-web3-server /usr/local/bin
- Copy config file into spike home
sudo mkdir -p /etc/spike/
sudo cp ./config.toml /etc/spike/config-web3.toml
- Startup script
sudo vim /etc/systemd/system/spike-web3-server.service
Specify the path to the binary
[Service]
ExecStart=/usr/local/bin/spike-web3-server
Environment=SPIKE_WEB3_CONFIG=/etc/spike/config.toml
Restart=always
RestartSec=5
sudo systemctl daemon-reload
sudo systemctl start spike-web3-server.service
sudo journalctl -u spike-web3-server.service -f
By default, spike-web3-server reads configuration from config.toml under the current folder. If it is not created, you may copy from config-example.config. If you need to specify the config file, you may set the enviornment as follows:
export SPIKE_WEB3_CONFIG=~/spike_home/config-web3.toml
# create database, replace 'spike_web3_server' with DbName config
mysql -u root -p <sql/create_db.sql
# create tables
mysql -u root -p spike_web3_server < sql/create_tables.sql
If you run the project successfully, you can visit http://localhost:3000/swagger/index.html. And you can see some interface information.