A Go SDK for interacting with Hauska smart contracts, providing idiomatic Go interfaces for blockchain-based digital asset management and licensing.
- Full package structure and modular organization
- All core types, interfaces, and service definitions
- High-level client API design
- Error definitions and usage examples
- Contract bindings generated using
abigen
- Automated build script with ABI extraction
- Full implementation of service methods using contract bindings
- Network integration and testing
- Documentation and unit tests
sdk/
├── go.mod
├── sdk.go # Main SDK entrypoint
├── config.go # Config definitions
├── errors.go # Error constants
├── types/ # Core domain types
├── services/ # Contract logic layer
├── client/ # High-level interface layer
├── contracts/ # Contract bindings (generated)
├── utils/ # Utility helpers
└── examples/ # Sample usage patterns
Contract Bindings: The contracts/
directory contains auto-generated Go bindings for all Hauska smart contracts, created using abigen
and the automated build script.
The Hauska Go SDK follows a layered architecture that provides clean separation of concerns and intuitive APIs for blockchain interaction:
┌─────────────────────────────────────┐
│ SDK (main.go) │ ← Main entry point
├─────────────────────────────────────┤
│ Clients (client/) │ ← High-level API layer
├─────────────────────────────────────┤
│ Services (services/) │ ← Business logic layer
├─────────────────────────────────────┤
│ Contracts (contracts/) │ ← Auto-generated bindings
├─────────────────────────────────────┤
│ Ethereum Blockchain │ ← Smart contracts
└─────────────────────────────────────┘
types/
: Core data structures, domain models, and shared interfacescontracts/
: Auto-generated contract bindings (viaabigen
) for direct blockchain interactionservices/
: Business logic layer handling transaction management, validation, and error handlingclient/
: High-level, user-friendly API abstractions over service operationsutils/
: Utility functions for address validation, amount conversions, and common operationsconfig.go
: Centralized configuration with Ethereum client setup and contract addresses
// User calls SDK
sdk.Factory.CreateOrganization(ctx, principal, partner)
↓
// Client delegates to service
factoryClient.service.CreateOrganization(ctx, principal, partner)
↓
// Service calls contract binding
factoryContract.CreateContract(opts, principal, partner)
↓
// Contract binding makes blockchain call
ethereum.Call() → Smart Contract on blockchain
This design provides separation of concerns, testability, and extensibility while maintaining clean, intuitive APIs for developers.
config := &hauska.Config{
Client: ethClient, // Ethereum client
FactoryAddress: "0xFactoryContractAddress", // Deployed Factory contract
USDCAddress: "0xUSDCContractAddress", // Deployed USDC ERC20
PrivateKey: "...", // User's private key
ChainID: 1, // Ethereum mainnet
GasLimit: 300000,
GasPrice: big.NewInt(20000000000),
}
go get github.com/ardata-tech/hauska-go
package main
import (
"context"
"log"
"github.com/ardata-tech/hauska-go"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
client, _ := ethclient.Dial("http://localhost:8545")
config := &hauska.Config{
Client: client,
FactoryAddress: "0x...",
USDCAddress: "0x...",
PrivateKey: "...",
}
sdk, err := hauska.New(config)
if err != nil {
log.Fatal(err)
}
// Example call
orgs, err := sdk.Clients.Factory.GetAllOrganizations(context.Background())
if err != nil {
log.Printf("Expected (scaffold): %v", err)
}
}
Defined in errors.go
, the SDK includes:
ErrInvalidClient
,ErrMissingAuth
– misconfigured SDKErrContractNotFound
,ErrTransactionFailed
– blockchain issuesErrAssetNotFound
,ErrLicenseNotFound
– logical not-found errors