Giter Club home page Giter Club logo

tron-api's Introduction

tron api sdk

地址

生成地址 私钥

 addr, PrivateKey, err := address.CreatAddress(pwd)
	 if err != nil {
	 	fmt.Printf("err :%s", err.Error())
	 	return
	 }

解密私钥

    PrivateKey, err := address.GetPrivateKey(pwd, PrivateKey)
     if err != nil {
	 	fmt.Printf("err :%s", err.Error())
	 	return
	 }

验证地址

    if address.ValidAddress(addr){
        fmt.Println("地址:合法")
    }else{
        fmt.Println("地址不合法")
    }

获取指定区块取件

    ApiKeys := []string{
		"9e3b28c4-3fd3-48c9-97af-ce4af055bcbb",
		"e29b2bc3-acba-4fe1-b784-ea54dafd0b6d",
	}
	client := api.NewClient(33251080,"",ApiKeys)
	client.GetBlockByLimitNext(func(data *model.TransferData) {
		fmt.Println(data)
	})
    select {}

发起交易

    // 初始化设置
   ContractMap := make(map[string]*model.ContractModel)
	ContractMap["TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"] = &model.ContractModel{
		Name:     "USDT",
		Type:     "trc20",
		Contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
		Decimal:  6,
	}
	rpc.SetContractMap(ContractMap)
    // 发起交易
	txid, err := rpc.NewRpc().Sen(PrivateKey, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "TD1HSXrv756gehQj1fi9hEUfVkheR9G4DV", decimal.NewFromFloat(0.01))
	if err != nil {
		g.Log().Error(err)
		return
	}
	fmt.Println(txid)

tron-api's People

Contributors

xpp777 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.