/go-dapp-example

DApp example of deploying and interacting with Solidity smart contract using Go.

Primary LanguageGoMIT LicenseMIT

Go-DApp-Example

DApp example of deploying and interacting with Solidity smart contract using Go.

🛠 Built With

Go Badge Gin Badge Geth Badge Solidity Badge

⚙️ Run Locally

Clone the project.

git clone https://github.com/tr1sm0s1n/go-dapp-example.git
cd go-dapp-example

Install abigen.

go install github.com/ethereum/go-ethereum/cmd/abigen@latest

Generate Go binding for contract.

abigen --bin lib/Cert.bin --abi lib/Cert.abi --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 paste it in .env.

PRIVATE_KEY=<private-key>

Deploy the contract.

go run ./cmd/deploy.go

Copy the contract address from the terminal and paste it in .env.

CONTRACT_ADDRESS=<contract-address>

Start the application.

go run .

Start the event listener (new terminal).

go run ./events/events.go

Issue a certificate (new terminal).

curl -X POST http://localhost:8080/issue -H "Content-Type: application/json" -d '{"id": "test-01", "name": "Shepard", "course": "ETH-GO", "grade": "A", "date": "22-11-23"}'

Fetch a certificate.

curl http://localhost:8080/fetch/test-01

Get event logs.

curl http://localhost:8080/events

📜 License

Click here.

🎗️ Contributing

Click here.

⚖️ Code of Conduct

Click here.