GithubHelp home page GithubHelp logo

xasset-sdk-go's Introduction

XASSET GO SDK

概述

本项目提供Xasset Go语言版的开发者工具包(SDK),开发者可以基于该SDK使用Go语言接入到Xasset平台。

使用说明

  • 1.从平台申请获得到API准入AK/SK。注意AK/SK是准入凭证,不要泄露,不要下发或配置在客户端使用。
  • 2.在开发中导入(import)对应包,开发业务程序。建议使用go mod管理包依赖。
  • 3.接入联调环境联调测试,测试通过后更换到线上环境,完成接入。

运行环境

GO SDK可以在go1.3及以上环境下运行。

导入SDK包


// 按需导入对应包使用,使用go mod管理(go mod tidy)
import (
    "github.com/xuperchain/xasset-sdk-go/client/xasset"
)

配置说明


type XassetCliConfig struct {
    // 请求接入Host
    Endpoint           string
    // 请求UA
    UserAgent          string
    // 准入授权信息,注意保密
    Credentials        *auth.Credentials
    // 准入签名Header
    SignOption         *auth.SignOptions
    // Http请求链接超时
    ConnectTimeoutMs   int
    // Http请求读写超时
    ReadWriteTimeoutMs int
}

// 使用示例
cfg := config.NewXassetCliConf()
cfg.Endpoint = "http://127.0.0.1:8360"
cfg.SetCredentials(appId, ak, sk)

使用示例


// 导入包
import (
    "github.com/xuperchain/xasset-sdk-go/client/xasset"        
    "github.com/xuperchain/xasset-sdk-go/common/config"
)

// 配置SDK
cfg := config.NewXassetCliConf()
cfg.Endpoint = "http://127.0.0.1:8360"
cfg.SetCredentials(appId, ak, sk)

// 调用SDK方法,可以参考单元测试
handle, _ := xasset.NewAssetOperCli(cfg, &Logger{})
handle.CreateAsset()

sk加解密

//导入包
import (
    github.com/xuperchain/xasset-sdk-go/utils
)

// 使用sk对str加密/解密
encodeStr, _ := utils.AesEncode(unionId, sk)
decodeStr, _ := utils.AesDecode(unionId, sk)

// 需要先加密后传输的应用场景在api中已经实现了该加密过程,不需要调用该函数
// POST /xasset/did/v1/bdboxregister返回的mnemonic已经实现了解密

xasset-sdk-go's People

Contributors

aucusaga avatar chunhui01 avatar cjqpker avatar ff629 avatar freshmand avatar girlfriend0 avatar hundredwz avatar wellzm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.