-
Notifications
You must be signed in to change notification settings - Fork 179
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
Polkadot cannot sign DynamicExtrinsic #401
Comments
Using the previous approach is also not feasible func Transfer(keyingPair signature.KeyringPair) {
// Instantiate the API
api, err := gsrpc.NewSubstrateAPI("wss://polkadot-rpc.dwellir.com")
if err != nil {
panic(err)
}
meta, err := api.RPC.State.GetMetadataLatest()
if err != nil {
panic(err)
}
bob, err := types.NewMultiAddressFromHexAccountID("0x1e635742bc09f1299c2934cbc46266a8c6b5756bc261fc0a970b6a51d1a4d053")
if err != nil {
panic(err)
}
// 0.1 unit of transfer
bal, ok := new(big.Int).SetString("1000000000", 10)
if !ok {
panic(fmt.Errorf("failed to convert balance"))
}
c, err := types.NewCall(meta, "Balances.transfer_keep_alive", bob, types.NewUCompact(bal))
if err != nil {
panic(err)
}
// Extrinsic
ext := types.NewExtrinsic(c)
genesisHash, err := api.RPC.Chain.GetBlockHash(0)
if err != nil {
panic(err)
}
rv, err := api.RPC.State.GetRuntimeVersionLatest()
if err != nil {
panic(err)
}
key, err := types.CreateStorageKey(meta, "System", "Account", keyingPair.PublicKey)
if err != nil {
panic(err)
}
var accountInfo types.AccountInfo
ok, err = api.RPC.State.GetStorageLatest(key, &accountInfo)
if err != nil || !ok {
panic(err)
}
encodedExt, err := codec.EncodeToHex(ext)
if err != nil {
panic(err)
}
fmt.Printf("Ext - %s\n", encodedExt)
options := types.SignatureOptions{
BlockHash: genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(accountInfo.Nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
TransactionVersion: rv.TransactionVersion,
}
err = ext.Sign(keyingPair, options)
if err != nil {
panic(err)
}
txHash, err := api.RPC.Author.SubmitExtrinsic(ext)
if err != nil {
panic(err)
}
fmt.Println(txHash.Hex())
} |
@YuXiaoCoder Please try using the latest version of dynamic extrinsic signing, and by using these extensions when signing in your first example:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error message:
panic: creating payload: signed extension 'PrevalidateAttests' is not supported
Here's the sample code
The text was updated successfully, but these errors were encountered: