Skip to content

Sagleft/go-nvs

Repository files navigation

logo

Emercoin NVS lib written in Go

GoDoc go-report


Install

go get github.com/sagleft/go-nvs

Usage example

Create client:

client, err := gonvs.NewClient(gonvs.CreateClientTask{
	RPCUser:     os.Getenv("USER"),
	RPCPassword: os.Getenv("PASSWORD"),
})
if err != nil {
	log.Fatalln(err)
}

Write new data to the blockchain:

err = client.Write(gonvs.WriteEntryTask{
	Name:  "test:" + uuid.NewString(),
	Value: []byte("entry value"),
	Days:  30,
})
if err != nil {
	log.Fatalln(err)
}

Get a list of records at the address:

address := os.Getenv("ADDRESS")
entrys, err := client.GetEntrysByAddress(gonvs.GetEntrysByAddressTask{
	Address: address,
})
if err != nil {
	log.Fatalln(err)
}

fmt.Println("NVS entrys for address `" + address + "`:")
for _, entry := range entrys {
	fmt.Println("    " + entry.Name)
}

Donate

logo

Ed1epQAF8TW5VDhZUusf4MsMNpNh9UMzm2