Go SDK for JEP: A Judgment Event Protocol.
Implements all 4 core primitives: Judgment, Delegation, Termination, Verification.
go get github.com/jep-protocol/sdk-gopackage main
import (
"fmt"
"log"
"github.com/jep-protocol/sdk-go"
)
func main() {
// Create client with API key
client := jep.NewClient("your-api-key")
// 1. Record a judgment
judgment, err := client.Judgment(&hjs.JudgmentRequest{
Entity: "alice@bank.com",
Action: "loan_approved",
Scope: map[string]interface{}{
"amount": 100000,
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("β
Judgment recorded: %s\n", judgment.ID)
// 2. Create a delegation
delegation, err := client.Delegation(&jep.DelegationRequest{
Delegator: "manager@company.com",
Delegatee: "employee@company.com",
Scope: map[string]interface{}{
"permissions": []string{"approve_under_1000"},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("β
Delegation created: %s\n", delegation.ID)
// 3. Verify the record
verification, err := client.Verify(delegation.ID)
if err != nil {
log.Fatal(err)
}
fmt.Printf("β
Verification result: %s\n", verification.Status) // "VALID" or "INVALID"
}// Create client with default settings (https://api.jep.sh)
client := jep.NewClient("your-api-key")
// Create client with custom base URL
client := jep.NewClientWithURL("https://your-jep-instance.com", "your-api-key")resp, err := client.Judgment(&jep.JudgmentRequest{
Entity: "user@example.com", // Required: who is making the judgment
Action: "approve", // Required: what action
Scope: map[string]interface{}{ // Optional: additional context
"amount": 1000,
"currency": "USD",
},
Immutability: map[string]interface{}{ // Optional: anchor to blockchain
"type": "ots",
},
})Response:
type JudgmentResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Protocol string `json:"protocol"`
Timestamp time.Time `json:"timestamp"`
}resp, err := client.Delegation(&jep.DelegationRequest{
Delegator: "manager@company.com", // Required: who delegates
Delegatee: "employee@company.com", // Required: who receives
JudgmentID: "jgd_xxx", // Optional: linked judgment
Scope: map[string]interface{}{ // Optional: delegation scope
"permissions": []string{"read", "write"},
},
Expiry: "2026-12-31T23:59:59Z", // Optional: expiration time
})resp, err := client.Termination(&hjs.TerminationRequest{
Terminator: "admin@company.com", // Required: who terminates
TargetID: "dlg_1234567890abcd", // Required: what to terminate
TargetType: "delegation", // Required: "judgment" or "delegation"
Reason: "Employee left company", // Optional: reason
})// Detailed verification
resp, err := client.Verification(&jep.VerificationRequest{
Verifier: "auditor@company.com",
TargetID: "dlg_1234567890abcd",
TargetType: "delegation", // "judgment", "delegation", or "termination"
})
// Quick verify (auto-detects type from ID prefix)
resp, err := client.Verify("dlg_1234567890abcd")// Get by ID
judgment, err := client.GetJudgment("jgd_xxx")
delegation, err := client.GetDelegation("dlg_xxx")
termination, err := client.GetTermination("trm_xxx")
// List with filters
judgments, err := client.ListJudgments(&jep.ListJudgmentsParams{
Entity: "user@example.com",
Page: 1,
Limit: 20,
})// Health check
health, err := client.Health()
// API documentation
docs, err := client.Docs()
// Generate API key
key, err := client.GenerateKey("user@example.com", "my-app")# Clone the repository
git clone https://github.com/jep-protocol/sdk-go.git
cd sdk-go
# Run tests
go test -v ./...
# Run example
go run examples/main.goresp, err := client.Judgment(&jep.JudgmentRequest{
Entity: "user@example.com",
Action: "approve",
})
if err != nil {
switch e := err.(type) {
case *jep.APIError:
fmt.Printf("API error: %s (status: %d)\n", e.Message, e.StatusCode)
case *jep.ValidationError:
fmt.Printf("Validation error: %s\n", e.Message)
default:
fmt.Printf("Unexpected error: %v\n", e)
}
return
}MIT License β see LICENSE for details.
Contributions are welcome! Please:
- Open an Issue for bugs or suggestions
- Submit Pull Requests for improvements
- See our Contributing Guide and Code of Conduct
Β© 2026 HJS Foundation Ltd.