单笔转账(代码)

package Sing

import (
    "fmt"
    ont "github.com/ontio/ontology-go-sdk"
    "github.com/ontio/ontology/account"
    "github.com/ontio/ontology/common"
    "time"
)

var (
    OntSdk *ont.OntologySdk
    Passwd   = []byte("1107")
    GasPrice = uint64(0)
    GasLimit = uint64(20000)
    //Addr1   *ont.Account
    addr1,_= common.AddressFromBase58("ATFBjDmoyvj7HcUMMJ7VfGiE8WupGypT2i")
    addr2,_= common.AddressFromBase58("APCWAUjgRmu1eLEc651GacsvKzTTfEUVhd")
)

func Getbanlance(){
    OntSdk = ont.NewOntologySdk()
    OntSdk.NewRpcClient().SetAddress("http://127.0.0.1:20336")
    balance1,_ := OntSdk.Native.Ont.BalanceOf(addr1)
    balance2,_ := OntSdk.Native.Ont.BalanceOf(addr2)
    fmt.Print(balance1)
    fmt.Print(balance2)


}

func GetTx(){

    wallet,err:= ont.OpenWallet("/Users/onchain/Desktop/ontology-1/wallet.dat")
    if err != nil {
        fmt.Printf("account.Open error:%s\n", err)
        return
    }


    Addr1, err := wallet.GetDefaultAccount(Passwd)
    if err != nil {
        fmt.Printf("GetDefaultAccount error:%s\n", err)
        return
    }
    TxHash,_ := OntSdk.Native.Ont.Transfer(GasPrice, GasLimit,Addr1,addr2,1)
    fmt.Print(TxHash)


func GetBAS(){
    time.After(6)
    //balance1,_ := OntSdk.Native.Ont.BalanceOf(addr1)
    balance2,_ := OntSdk.Native.Ont.BalanceOf(addr2)


    fmt.Print(balance2)
}

你可能感兴趣的:(单笔转账(代码))