Skip to content

virtualeconomy/go-vsys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-vsys

The official Golang SDK for VSYS APIs

License

Under active development. Contributions are always welcome!

The official Golang SDK for VSYS APIs. The old Golang SDK is deprecated and will be archived soon.

Installation

Install from Github using go get:

go get github.com/virtualeconomy/go-vsys

Quick Example

package main

import (
	"fmt"

	"github.com/virtualeconomy/go-vsys/vsys"
)

const (
	HOST = "http://veldidina.vos.systems:9928"
	SEED = "your seed"
)

func printHeading(s string) {
	fmt.Printf("============= %s ============\n", s)
}

func main() {
	printHeading("Try out NodeAPI")
	// NodeAPI is the wrapper for REST APIs exposed by VSYS network nodes.
	api := vsys.NewNodeAPI(HOST)
	fmt.Println(api)

	// GET /blocks/height
	resp, _ := api.GetCurBlockHeight()
	fmt.Println(resp.Height)

	printHeading("Try out Chain")
	// Chain represents the blockchain.
	ch := vsys.NewChain(api, vsys.TEST_NET)
	fmt.Println(ch)

	// Get chain's height
	height, _ := ch.Height()
	fmt.Println(height)

	printHeading("Try out Account")
	// Wallet represents the wallet where there's a seed phrase.
	wal, _ := vsys.NewWalletFromSeedStr(SEED)
	fmt.Println(wal)

	// Account represents an account in the blockchain network.
	acnt, _ := wal.GetAccount(ch, 0)
	fmt.Println(acnt)

	printHeading("Try out Smart Contract")
	const ctrtId = "CF3cK7TJFfw1AcPk74osKyGeGxee6u5VNXD"
	nc, _ := vsys.NewNFTCtrt(ctrtId, ch)

	// Get the contract's ID
	fmt.Println("Contract id:", nc.CtrtId)
}

Docs

Account & Wallet

Chain & API

Smart Contracts

Testing

Functional tests are functions that simulate the behavior of a normal user to interact with go-vsys(e.g. register a smart contract & call functions of it).

NOTE that the test environement defined as global variables in helper_test.go has to be configured through environemnt variables before the test cases can be executed.

Then go to the root of the project and run.

go test ./vsys/ -v -timeout 0 -run AsWhole

timeout is needed to avoid default 10min limit for running tests. With -run flag you can supply regexp for tests to run.

The above command will run functions that tests contracts as a whole i.e. without setting up new resources per each function test. If you want to test individual contracts or functions:

go test ./vsys/ -v -timeout 0 -run NFTCtrt_Supersede

Test function names are made so that you can run all functions of certain contract by supplying its name to -run argument. Then can add function name as suffix to test specific function.

More information on how to run tests can be found in testing package documentation.

Contributing

Contributions are always welcome!

See the development documentation for more details and please adhere to conventions mentioned in it.

About

The official Golang SDK for VSYS APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages