Closed May5thg closed 4 years ago
Source code package main
import ( "encoding/json" "fmt" "github.com/goat-systems/go-tezos" "math/big" )
func main() {
//mnem := mnemonic.GenerateSeed()
//wt, err := gotezos.CreateWallet(mnem, "111")
//if err != nil {
// fmt.Println("地址生成错误:", err)
// return
//}
//
//fmt.Println(wt.Address)
//fmt.Println(mnem)
//fmt.Println(wt.Pk)
//fmt.Println(wt.Sk)
//fmt.Println()
//
//return
input := gotezos.Contents{
Source: "tz1iMwhMv5er5zuNePwSKKTkVifKCHQzKpGM",
Fee: &gotezos.Int{big.NewInt(1800)},
Counter: &gotezos.Int{big.NewInt(3720136)},
GasLimit: &gotezos.Int{big.NewInt(10800)},
StorageLimit: &gotezos.Int{big.NewInt(0)},
Kind: gotezos.TRANSACTIONOP,
Amount: &gotezos.Int{big.NewInt(7000)},
Destination: "tz1aGF7gRhQJY28HVmBY1KazxyxkRvrSvXQ3",
}
//创建交易
raw, err := gotezos.ForgeOperation("BKitDwkC44UaxavS5F3RHcYgnn3SfmUKVj8ATmRnuPDW6AzqeGH", input)
if err != nil {
fmt.Println("创建交易失败,err:", err)
return
}
// 签名
wallet, err := gotezos.ImportWallet("tz1iMwhMv5er5zuNePwSKKTkVifKCHQzKpGM",
"edpkuSN8XqLifzbdUgiJDMsjXgeeQuMqFQjFh1esJjhqx82raaZ3Ah",
"edskS5rTiLv2YhXzFFxt44xmvZNjhjCJ7diz9GsL7NtpjKENcw43KSgo5qHhNeC8WmBxHrWjF9mmpT155RPev2cQ1kwNmrUX7E")
//wallet, err := gotezos.ImportEncryptedWallet("111","edesk1xJx2K758UyyRqd9NgcDy4vY1wVQfsSrsaTn2Tm3Zdq2bSLSTe8uR42SpxaZ3eJtDG9VDAt7EPzgP8P6HXJ")
if err != nil {
fmt.Println("实例化钱包失败,err:", err)
return
}
//fmt.Println(wallet.Address, wallet.Sk)
sigop, err := wallet.SignOperation(*raw)
if err != nil {
fmt.Println("签名失败,err:", err)
return
}
//广播
gt, err := gotezos.New("http://xxx.xx.xx.xx:8732")
if err != nil {
fmt.Printf("could not connect to network: %v", err)
return
}
txidByte, err := gt.InjectionOperation(gotezos.InjectionOperationInput{
Operation: &sigop,
})
var res interface{}
err = json.Unmarshal(txidByte, &res)
if err != nil {
fmt.Println("解析失败", err)
return
}
fmt.Println(res)
}
@DefinitelyNotAGoat Can you help me with the trouble? I once transferred two transactions to tz1iMwhMv5er5zuNePwSKKTkVifKCHQzKpGM
resolved
resolved
大佬,这个问题你是如何解决的?
Do offline generated addresses need to be activated at the node to be used? What are the activated commands? When I use the offline generated address for transfer, I reported the following error enter image description here