Skip to content

OwnMarket/own-blockchain-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

own-blockchain-sdk-go

Own Blockchain SDK for Go

Quick Start

$ git clone https://github.com/OwnMarket/own-blockchain-sdk-go.git
$ cd own-blockchain-sdk-go

Run tests:

$ go test -v

Usage

Fetch Own Blockchain SDK for Go package

$ go get github.com/OwnMarket/own-blockchain-sdk-go

Use the package in Go code

package main

import (
	"fmt"

	ownSdk "github.com/OwnMarket/own-blockchain-sdk-go"
)

func main() {
	// Create a new wallet
	wallet := ownSdk.GenerateWallet()

	// Compose a transaction with nonce = 1 and actionFee = 0.1
	tx := ownSdk.CreateTx(wallet.Address, 1, 0.1, 0)
	tx.AddTransferChxAction("CHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 100) // Transfer 100 CHX to CHxxx... address.

	// Look at the raw transaction in JSON format
	fmt.Println(tx.ToJson(true))

	// Sign the transaction for submission to node API on TestNet
	networkCode := "OWN_PUBLIC_BLOCKCHAIN_TESTNET"
	signedTx := tx.Sign(networkCode, wallet.PrivateKey)
	fmt.Println(signedTx.ToJson(false))
}

Releases

No releases published

Packages

No packages published

Languages