Code Monkey home page Code Monkey 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

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

Stargazers

 avatar 人群里的蚂蚁 avatar Alon Chen avatar lewis avatar  avatar  avatar  avatar cat-pudding avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

xasset-sdk-go's Issues

依赖版本错误

TestGetStoken 失败

应该是版本依赖过低

Running tool: /usr/local/go/bin/go test -timeout 30s -run ^TestGetStoken$ github.com/xuperchain/xasset-sdk-go/client/xasset

github.com/consensys/gurvy/bls377/fr

/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bls377/fr/element.go:517:2: undefined: fromMontElement
/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bls377/fr/element.go:530:2: undefined: mulAssignElement

github.com/consensys/gurvy/bn256/fr

/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bn256/fr/element.go:517:2: undefined: fromMontElement
/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bn256/fr/element.go:530:2: undefined: mulAssignElement

github.com/consensys/gurvy/bls381/fr

/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bls381/fr/element.go:517:2: undefined: fromMontElement
/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bls381/fr/element.go:530:2: undefined: mulAssignElement

github.com/consensys/gurvy/bn256/fp

/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bn256/fp/element.go:517:2: undefined: fromMontElement
/Users/manfeiqi/go/pkg/mod/github.com/consensys/[email protected]/bn256/fp/element.go:530:2: undefined: mulAssignElement
FAIL github.com/xuperchain/xasset-sdk-go/client/xasset [build failed]

无法创建资产

使用命令go test -v -run TestXasset 后返回如下
[lvl:Warn] get resp failed. [url: http://120.48.16.137:8360/xasset/horae/v1/create] [request_id: 2933048228798160161] [err_no: 40001] [trace_id: 0] [sdk_call:asset.go:221]

对比之后发现是参数错误 请问测试环境不支持创建资产吗

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.