Skip to content

hashkeydid/hashkeydid-go

Repository files navigation

HashKey DID Go SDK

Tag Go Reference License Go Report Card

Go module to work with HashKey DID Protocol.

Installation

go get github.com/hashkeydid/hashkeydid-go

Usage

hashkeydid-go provides simple access to the HashKey DID Contracts.

Core

hashkeydid-go.Core is the core struct of this project to use this SDK function.

core, err := hashkeydid.NewDIDCore("rpc url")

Opts

To query the historical info of DID, SDK provides an option arg called opts. User can query the status with a custom block height.

// query the status on Block 40069811
opts := &bind.CallOpts{BlockNumber: big.NewInt(40069811)}

Sample1-GetName

// after user set reverse
name, err := core.GetDIDNameByAddr(opts, address)

Sample2-GetAvatar

In HashKey DID, avatarUrl supports many forms (Detail).

chainList is a map which includes information of chains. SDK provides a default chainList for user to query on-chain status. User can provide a list with custom chainIds and RPCUrls.

chainList in args can be nil.

// query by DID name
avatar, err := core.GetAvatarByDIDName(opts, name)

// query by tokenId
avatar, err := core.GetAvatarByTokenId(opts, tokenId)