// Install: go get github.com/aethelred/sdk-go
package main
import (
"context"
"fmt"
"time"
"github.com/aethelred/sdk-go/client"
"github.com/aethelred/sdk-go/jobs"
"github.com/aethelred/sdk-go/types"
)
func main() {
ctx := context.Background()
c, err := client.NewClient(client.Testnet)
if err != nil {
panic(err)
}
submit, err := c.Jobs.Submit(ctx, jobs.SubmitRequest{
ModelHash: "09f7e2b3c5d6a1f9f7e2b3c5d6a1f9f7e2b3c5d6a1f9f7e2b3c5d6a1f9f7e2b3",
InputHash: "f4d3a381d89f9f7a35bfa48d9b5f9d7c6c18d2a8b431c1d6a2d2d413c3e7ed09",
ProofType: types.ProofTypeHybrid,
Priority: 5,
MaxGas: "1000000",
TimeoutBlocks: 120,
Metadata: map[string]string{"source": "developers-quickstart"},
})
if err != nil {
panic(err)
}
fmt.Printf("job id: %s\n", submit.JobID)
job, err := c.Jobs.WaitForCompletion(ctx, submit.JobID, 2*time.Second, 120*time.Second)
if err != nil {
panic(err)
}
if job.Status != types.JobStatusCompleted {
panic(fmt.Sprintf("job failed with status %s", job.Status))
}
seals, err := c.Seals.List(ctx, nil)
if err != nil {
panic(err)
}
var sealID string
for _, seal := range seals {
if seal.JobID == job.ID {
sealID = seal.ID
break
}
}
if sealID == "" {
panic(fmt.Sprintf("no seal found for job %s", job.ID))
}
verification, err := c.Seals.Verify(ctx, sealID)
if err != nil {
panic(err)
}
fmt.Printf("seal valid: %t\n", verification.Valid)
}