From 6e1876c2d81b48a80ede344b3d90f80495b237b2 Mon Sep 17 00:00:00 2001
From: Rob Brackett <rob@robbrackett.com>
Date: Mon, 18 Jun 2018 13:46:40 -0700
Subject: [PATCH] Add a usage example to the README, fixes #9

We could still use some more examples of other operations, but this should be a good start.

License: MIT
Signed-off-by: Rob Brackett <rob@robbrackett.com>
---
 README.md | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/README.md b/README.md
index ca2dbd7..75d7ca3 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,35 @@
 This package contains all of components necessary to create, understand, and
 validate IPNS records.
 
+## Usage
+
+To create a new IPNS record:
+
+```go
+import (
+	"time"
+
+	ipns "github.com/ipfs/go-ipns"
+	crypto "github.com/libp2p/go-libp2p-crypto"
+)
+
+// Generate a private key to sign the IPNS record with. Most of the time, 
+// however, you'll want to retrieve an already-existing key from IPFS using the
+// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
+privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
+
+// Create an IPNS record that expires in one hour and points to the IPFS address
+// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
+ipnsRecord, err := ipns.Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
+if err != nil {
+	panic(err)
+}
+```
+
+Once you have the record, you’ll need to use IPFS to *publish* it.
+
+There are several other major operations you can do with `go-ipns`. Check out the [API docs](https://godoc.org/github.com/ipfs/go-ipns) or look at the tests in this repo for examples.
+
 ## Documentation
 
 https://godoc.org/github.com/ipfs/go-ipns
-- 
GitLab