SDK
Go SDK
Official Go SDK for SwiftProof. Requires Go 1.21 or later.
Installation
terminal
go get github.com/swiftproof/swiftproof-go
Initialisation
Go
import ( "os" swiftproof "github.com/swiftproof/swiftproof-go" ) client := swiftproof.New(os.Getenv("SWIFTPROOF_API_KEY"))
Create a chain
Go
chain, err := client.Chains.Create(ctx, &swiftproof.CreateChainParams{ Title: "Order #4821", Actors: []swiftproof.Actor{ {Event: "packed", Actor: "Kitchen"}, {Event: "collected", Actor: "Rider — Emeka"}, {Event: "delivered", Actor: "Rider — Emeka"}, }, }) if err != nil { log.Fatal(err) } fmt.Println(chain.ChainID) fmt.Println(chain.TrackingURL)
Verify a chain
Go
proof, err := client.Chains.Verify(ctx, "sp_ch_a96fec076ffd44f4") if err != nil { log.Fatal(err) } if proof.Tampered { log.Fatal("chain integrity check failed") } for _, step := range proof.Trail { fmt.Printf("%s at %s — %s\n", step.Event, step.ConfirmedAt, step.Location) }