https://github.com/tr1sm0s1n/go-dapp-example
DApp example of deploying and interacting with Solidity smart contract using Go.
https://github.com/tr1sm0s1n/go-dapp-example
api dapp ethereum events gin gin-gonic go go-ethereum golang smart-contracts solidity websocket
Last synced: 3 months ago
JSON representation
DApp example of deploying and interacting with Solidity smart contract using Go.
- Host: GitHub
- URL: https://github.com/tr1sm0s1n/go-dapp-example
- Owner: tr1sm0s1n
- License: mit
- Created: 2023-07-21T14:30:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-11T16:58:37.000Z (about 2 years ago)
- Last Synced: 2024-05-12T15:52:17.248Z (about 2 years ago)
- Topics: api, dapp, ethereum, events, gin, gin-gonic, go, go-ethereum, golang, smart-contracts, solidity, websocket
- Language: Go
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Go-DApp-Example
DApp example of deploying and interacting with Solidity smart contract using Go.
## 🛠 Built With
[](https://go.dev/)
[](https://gin-gonic.com/)
[](https://geth.ethereum.org/)
[](https://soliditylang.org/)
## ⚙️ Run Locally
Clone the project.
```bash
git clone https://github.com/tr1sm0s1n/go-dapp-example.git
cd go-dapp-example
```
Install **abigen**.
```bash
go install github.com/ethereum/go-ethereum/cmd/abigen@latest
```
Generate Go binding for contract.
```bash
abigen --v2 --bin lib/Cert.bin --abi lib/Cert.json --pkg lib --type Cert --out lib/Cert.go
```
Run a blockchain simulation on port **8545** (both http & ws). Copy a valid private key (omit '0x') and export it.
```bash
export PRIVATE_KEY=
```
Deploy the contract.
```bash
go run ./cmd/deploy.go
```
Copy the contract address from the terminal and export it.
```bash
export CONTRACT_ADDRESS=
```
Start the application.
```bash
go run .
```
Start the event listener (new terminal).
```bash
go run ./events/events.go
```
Issue a certificate (new terminal).
```bash
curl -X POST http://localhost:8080/issue -H "Content-Type: application/json" -d '{"id": 626, "name": "Jane", "course": "MBCC", "grade": "A", "date": "04-06-25"}'
```
Fetch a certificate.
```bash
curl http://localhost:8080/fetch/626
```
Get event logs.
```bash
curl http://localhost:8080/events
```
## 📜 License
Click [here](./LICENSE.md).
## 🎗️ Contributing
Click [here](./CONTRIBUTING.md).
## ⚖️ Code of Conduct
Click [here](./CODE_OF_CONDUCT.md).