polkadot-js / extension

Simple browser extension for managing Polkadot and Substrate network accounts in a browser. Allows the signing of extrinsics using these accounts. Also provides a simple interface for compliant extensions for dapps.
Apache License 2.0
964 stars 403 forks source link

Transaction not broadcasting on bli0ckchain #1365

Closed shariquearshad closed 1 month ago

shariquearshad commented 1 month ago

Currently, we are integrating the Polkadot.js extension (https://polkadot.js.org/extension/) for swaps related to Polkadot. However, when sending a transaction, it doesn't seem to be getting broadcasted as I'm receiving status.isInBlock as false.

here is the code snippet

const wsProvider = new WsProvider('wss://rpc.polkadot.io'); const api = await ApiPromise.create({ provider: wsProvider }); const allInjected = await web3Enable('my cool dapp'); const allAccounts = await web3Accounts(); // api.setSigner(allInjected[0].signer) let const SENDER = '15iXHTv3akcJDNAc4HddWUuWxBLK55vSQiN98m6xcUemqfWg'; const reciever='15iBCDWRVBmqpVGh4JekqSekFyegpV2EXFXUoS6S4d73BVN6' // const transferExtrinsic = api.tx.balances.forceTransfer(reciever,1) const injector = await web3FromSource(allAccounts[0].meta.source); const unsub = await api.tx.balances .transferAllowDeath(reciever,bnToBn(1) ) .signAndSend(SENDER,{ signer: injector.signer }, (result: any) => { (result) const isInBlock = result?.status?.isInBlock if (!isInBlock) return const errorEvent = result?.events.find( ({ event: { method } }: any) => method === 'ExtrinsicFailed', ) if (isInBlock && errorEvent) { // Reject if ExtrinsicFailed event was found console.log("rejected") } else if (isInBlock) { // Otherwise resolve succesfully if transaction is in block return result

      }
    })
Tbaut commented 1 month ago

The broadcasting is not related to the extension, since its role is only to sign, not to broadcast. please check the polkadot/api examples: https://polkadot.js.org/docs/api/examples/promise/transfer-events

polkadot-js-bot commented 1 month ago

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.