Submit Extrinsic error by Creating ExtrinsicPayload and sign
See original GitHub issueI can’t make a transfer successfully, so I tired to generate extrinsicPayload and sign without creating signerPayload, but submitted extrinsic failed, could you please help me ? here’s the code and key pair:
it('totally-offline', async () => {
const wsProvider = new WsProvider('wss://westend-rpc.polkadot.io')
const from = '5FA5GKjtaCYHRhLtJ8bWhA1zP137PzTMmiDw8nfb5wDXSyGD';
const to = '5Dgq3axpAPE7nUDKdhsxfvHKjBiRTwCQJesfxZ2z12b91TC3';
const keyring = new Keyring({type: 'ed25519'});
const pair = keyring.addFromUri(****)
const api = await ApiPromise.create({provider: wsProvider});
const nonce = (await api.query.system.account(from)).nonce.toString();
const genesisHash = api._genesisHash.toString();
const version = api.extrinsicVersion;
const runtimeVersion = (await api._rpc.state.getRuntimeVersion());
const header = await api.rpc.chain.getHeader();
let current = header.number.toString()
let registry = new TypeRegistry();
let decorated = new Decorated(registry, metadataStatic);
new Metadata(registry, metadataStatic);
let tx = new Extrinsic(registry, decorated.tx.balances.transfer(to, 100));
let era = registry.createType('ExtrinsicEra', {current: current, period: 900});
let data = {
address: from,
blockHash: genesisHash,
// blockNumber: '',
era: era,
genesisHash: genesisHash,
method: tx.method.toHex(),
nonce: nonce,
// runtimeVersion: runtimeVersion,
// signedExtensions:signedExtensions,
specVersion: runtimeVersion.specVersion.toString(),
tip: '',
// transactionVersion: runtimeVersion.transactionVersion.toString(),
// version: version
}
let extrinsicPayload = new ExtrinsicPayload(registry, data, { version: 4 });
const {signature} = extrinsicPayload.sign(pair);
console.log('signature', signature)
let verifySignature = hex.hexToU8a(signature).subarray(1)
const verifyData = extrinsicPayload.toU8a(true);
let verifyResult = pair.verify(verifyData, verifySignature);
console.log('verifyResult', verifyResult)
tx.addSignature(from, signature, extrinsicPayload);
const hash = await api.rpc.author.submitExtrinsic(tx.toHex()
console.log(hash.toHex())
process.exit();
});
And always got the error:
1002: Verification Error: Execution(Wasmi(Trap(Trap { kind: Unreachable }))): RuntimeApi("Execution(Wasmi(Trap(Trap { kind: Unreachable })))
I don’t know what the problem is Can you please run my unit test and told me the result? thank you very much!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Tx.addSignature emiting error · Issue #4446 · polkadot-js/api
The extrinsic payload is signed, not the transaction. You are serializing the transaction and signing that. The payload has all transaction ...
Read more >Sending extrinsic fails when signed payload goes over 256 ...
The extrinsic started failing with error code 1010 BadProof (invalid signature) all of a sudden. I managed to validate all the data again, ......
Read more >Day in the Life of a Substrate Extrinsic - Unit 410
The Polkadot.js web UI does not show you the SCALE-encoded signer payload. It creates that on the fly when you click “Submit Transaction.”....
Read more >Errors and How to Resolve Them - Polkadot Wiki
Polkascan and Subscan show the ExtrinsicFailed event when a transaction does not succeed (example). This event gives us the error and index ...
Read more >Transactions in Off-chain Workers - Substrate Recipes
Unsigned transactions with signed payloads are used if the transaction requires ... This tell the runtime that this pallet can create signed transactions....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i’m so sad
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.