Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transfer coin error #22

Open
godlovericea opened this issue Jan 1, 2025 · 7 comments
Open

transfer coin error #22

godlovericea opened this issue Jan 1, 2025 · 7 comments

Comments

@godlovericea
Copy link

godlovericea commented Jan 1, 2025

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)
}
@godlovericea
Copy link
Author

The Help Center Link is not found, I can not open it:

Not Found
The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

@godlovericea
Copy link
Author

I have made a transaction successfully on Ghostnet with the RPC endpoint :[https://rpc.ghostnet.teztnets.com]

But I can not make transaction on mainnet,

Could you give me some RPC endpoint ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@godlovericea and others