We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi guys, First of all, thanks for developing an aptos sdk in golang. It really helps people like me :)
I ran into a problem while trying to do a simple transfer. Here is my code...
func transfert(from utils.Account, to utils.Account, aptosValue uint64) error { accountInfo, err := aptosClient.GetAccount(ctx, from.Address) if err != nil { return err } addr, _ := models.HexToAccountAddress(to.Address) tx := models.Transaction{} err = tx.SetChainID(settings.ChainID). SetSender(from.Address). SetPayload(getTransferPayload(addr, aptosValue*settings.AptosUnit)). SetExpirationTimestampSecs(uint64(time.Now().Add(10 * time.Minute).Unix())). SetGasUnitPrice(settings.GasPrice). SetMaxGasAmount(uint64(settings.MaxGasPrice)). SetSequenceNumber(accountInfo.SequenceNumber).Error() if err != nil { return err } msgBytes, err := tx.GetSigningMessage() if err != nil { panic(err) } var pk1, _ = hex.DecodeString(from.PrivateKeyHex[2:]) priv1 := ed25519.NewKeyFromSeed(pk1) signature := ed25519.Sign(priv1, msgBytes) var authErr = tx.SetAuthenticator(models.TransactionAuthenticatorEd25519{ PublicKey: priv1.Public().(ed25519.PublicKey), Signature: signature, }).Error() if authErr != nil { panic(authErr) } rawTx, err := aptosClient.SubmitTransaction(ctx, tx.UserTransaction) if err != nil { panic(err) } utils.Log(utils.Info, 0, "Transfert 1 APTOS from "+from.Address+" to "+to.Address+" TX: "+rawTx.Hash) return nil } func getTransferPayload(to models.AccountAddress, amount uint64) models.TransactionPayload { return models.EntryFunctionPayload{ Module: models.Module{ Address: addr0x1, Name: "coin", }, Function: "transfer", TypeArguments: []models.TypeTag{aptosCoinTypeTag}, Arguments: []interface{}{to, amount}, } }
As you can see, it is strongly inspired by your example script. The problem is that this part of the code triggers an error :
msgBytes, err := tx.GetSigningMessage() if err != nil { panic(err) }
Output : panic: non-optional enum value is nil
I don't see what my script is missing to make it work. I hope you can help me understand the problem if there is one. Thanks in advance.
The text was updated successfully, but these errors were encountered:
Is aptosCoinTypeTag initialized?
aptosCoinTypeTag
Sorry, something went wrong.
No branches or pull requests
Hi guys,
First of all, thanks for developing an aptos sdk in golang. It really helps people like me :)
I ran into a problem while trying to do a simple transfer.
Here is my code...
As you can see, it is strongly inspired by your example script. The problem is that this part of the code triggers an error :
Output : panic: non-optional enum value is nil
I don't see what my script is missing to make it work. I hope you can help me understand the problem if there is one. Thanks in advance.
The text was updated successfully, but these errors were encountered: