forked from blockwatch-cc/tzgo
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I want to transfer XTZ coin from my wallet address to another via golang program, but failed.
panic with error:
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x18111d7]
My code is below, please check, thanks!
func Make_XTZ_TX() {
key := "edsk33eeEJT5WoY7hgpHUCRd1qcYZcXu47vrdK8uYo65JYKqiPL9Qt"
fReceiver := "tz1RDL4YZ5e92ZLrv3z5YV1ppBQtovZbx7Bm"
sk, err := tezos.ParsePrivateKey(key)
if err != nil {
return
}
fAmount := "100000" // 0.1
c, err := rpc.NewClient("https://rpc.ghostnet.teztnets.com", nil)
if err != nil {
return
}
c.Signer = signer.NewFromKey(sk)
recv, err := tezos.ParseAddress(fReceiver)
if err != nil {
return
}
amount, err := strconv.ParseInt(fAmount, 10, 64)
if err != nil {
return
}
// construct batch operation
op := codec.NewOp().WithSource(sk.Address())
op.WithTransfer(recv, amount)
// send operation with default options
rcpt, err := c.Send(
context.Background(),
op,
&rpc.CallOptions{
IgnoreLimits: true,
},
)
if err != nil {
return
}
total := rcpt.TotalCosts()
fmt.Println("Costs")
fmt.Printf(" Total %d\n", total.Fee+total.StorageBurn+total.AllocationBurn)
fmt.Printf(" Baker Fee %d\n", total.Fee)
fmt.Printf(" Storage burn %d\n", total.StorageBurn)
fmt.Printf(" Allocation burn %d\n", total.AllocationBurn)
fmt.Printf(" Gas used %d\n", total.GasUsed)
fmt.Printf(" Storage bytes %d\n", total.StorageUsed)
if !rcpt.IsSuccess() {
return
}
hash := rcpt.Op.Hash.String()
fmt.Println("hash:", hash)
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels