Implementing Smart Contract in the Golang
- Golang
- Gin
- Solidity
- Ganache
- go-ethereum
- swag
- Docker
- Docker Compose
$ make setup
In "src/.env", set "GANACHE_HOST" to the network of the "geth" container
$ docker network inspect geth-dapp-demo-network
ex)
...
"Containers": {
...
"xxxx" : {
"Name": "geth", <- This is the name of the network to connect to the "geth" container.
}
}
- Please change your Ganache private key.
You can check Ganache's Private Key with this command.
$ make exec-geth
$ ganache
Delete the leading "0x" of the acquired Private Key and paste it.
./src/contract_address/contract_address.go
priKey := "Your Private Key"
- Get a Contract address.
$ make up
go to http://localhost:8080/swagger/index.html call http://localhost:8080/api/v1/contract-address
- Please change your contract address.
./src/controller/hello.go
constantAddress = "Your Contract Address"
If "Hello World" is displayed, it is successful!!
Compile the code in the ./contracts and output the Golang code in the ./src/contracts.
$ make sol-compile sol={solidity file name} go={golang file name}
ex)
make sol-compile sol=Hello go=hello
$ make generate-api-doc
SEE: https://github.com/swaggo/swag
$ make up
$ make down
$ make exec-src
$ make exec-geth