LogoLogo
  • Bluzelle GameFi Overview
  • Problem
  • The Solution
  • The BLZ Token
  • Careers
  • BLZ Staking
    • Bluzelle Staking Economics
    • Gas & Tax
    • Validator
      • Technical Requirements
      • Building a Public Validator + Sentry
      • Useful Commands
    • Delegator
  • GAMMA 4
    • Overview
    • The Story
    • Game Lite Paper
  • Bluzelle R2 - Decentralized Storage
    • Features
    • Architecture
    • Bluzelle Versus Filecoin
    • Deploy Your dApps
      • JS
      • Python
      • Go
      • Ruby
      • Java
    • CRUD Queries
  • Guide & Resources
    • Bridging between ERC20-BLZ and L1-BLZ
    • Create a Bluzelle Wallet
    • OS Setup for Curium
    • Development Environment Setup
    • Build the Curium Project
  • Useful Links
    • Bluzelle Website
    • Discord Developer and Validator Community
    • Twitter
Powered by GitBook
On this page
  • Getting started
  • Examples
  • Integration Tests
  • User Acceptance Testing
  • Licence
Export as PDF
  1. Bluzelle R2 - Decentralized Storage
  2. Deploy Your dApps

Go

PreviousPythonNextRuby

Last updated 4 years ago

Getting started

Ensure you have a recent version of installed.

Grab the package from github:

go get github.com/bluzelle/blzgo

Use:

package main

import (
  "github.com/bluzelle/blzgo"
  "log"
)

func main() {
  // create client
  options := &bluzelle.Options{
    Mnemonic: "...",
    Endpoint: "http://dev.testnet.public.bluzelle.com:1317",
    UUID: "...",
  }
  client, err := bluzelle.NewClient(options)
  if err != nil {
    log.Fatalf("%s", err)
  }

  key := "foo"
  value := "bar"

  gasInfo := bluzelle.GasInfo{
    MaxFee: 4000001,
  }
  leaseInfo := bluzelle.LeaseInfo{
    Days: 1,
  }

  // create key
  if err := client.Create(key, value, gasInfo, leaseInfo); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("create key success: true\n")
  }

  // read key
  if v, err := client.Read(key); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("read key success: %t\n", v == value)
  }

  // update key
  if err := client.Create(key, value, gasInfo, nil); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("create key success: true\n")
  }

  // delete key
  if err := client.Delete(key, gasInfo); err != nil {
    log.Fatalf("%s", err)
  } else {
    log.Printf("delete key success: true\n")
  }
}

Examples

You can test out the examples/ included by following these steps:

  1. Copy .env.sample to .env and configure if needed.

cp .env.sample .env
  1. Install dependencies:

go get ./...
  1. Run an example as defined in the Makefile, for example, to read the value of an existing key, foo, run:

make read key=foo

This will run the examples/crud/read.go.

Integration Tests

make test

User Acceptance Testing

Licence

MIT

Please checkout the document for more details.

UAT.md
Go