Questions tagged [polkadot-js]
Questions about the Polkadot-JS API used to interact with Substrate-based chains using JavaScript.
512
questions
1
vote
0
answers
35
views
BestWay The Restart Substrate Node
After adding the validator node, it may encounter issues preventing it from creating blocks and initiating the next era in the blockchain.
in this case,is there a way to restart the network?
keep the ...
0
votes
1
answer
26
views
How to properly decode a SCALE-encoded string using polkadot-js?
Using @polkadot-js/api, one can encode a string aabbcc into 0x18616162626363
> u8aToHex(api.createType('String', "aabbcc").toU8a())
"0x18616162626363"
I know that SCALE ...
2
votes
1
answer
24
views
Transaction pool management
I have to send thousands of transactions to a custom substrate chain, it will probably take a few days to process all of them. Of course I can't just send all the transactions at once because they ...
2
votes
1
answer
28
views
How to retrieve number of decimals for custom token (not DOT)?
How to retrieve number of decimals for custom token (not DOT)?
api.registry.chainDecimals is for DOT. I need to retrieve it for a custom token.
1
vote
0
answers
15
views
Why are payloads wrapped in a <Bytes> tag? [duplicate]
In Polkadot JS Apps, when signing a payload the payload is wrapped in a <Bytes> tag. E.g.
I put a few console log's in the polkadot JS apps code to figure out what's going on. As you can see, ...
1
vote
1
answer
27
views
Decode event data
I am learning to use polkadotjs api, I am trying to send a system.remarkWithEvent and then get the event that this created and decode de output to verify that the remark is there.
The sending of the ...
1
vote
1
answer
47
views
Issues approving transactions after updating parity signer
After a year of not using my Parity Signer, I attempted to approve a transaction using it. Initially, the signer displayed an error upon scanning the transaction QR code. In response, I updated the ...
1
vote
1
answer
31
views
Obtain the balance of erc20 tokens with Polkadot JS
I'm seeking a method to retrieve the balances of all ERC20 tokens associated with an account using the Polkadot JS API. I've been unable to locate a specific API call that enables this functionality. ...
1
vote
1
answer
114
views
Polkadot - westend/westmint: how to create a pool using the asset conversion pallet?
We want to create a pool and we need to provide asset1 and asset2 values to the function, we are not sure what those asset1 and 2 are exactly (we are not sure what it represents or where to find it).
...
1
vote
2
answers
35
views
system.ExtrinsicFailed Token.NotExpendable
I'm working on a project that involves setting up a shared pot account. Anyone can fund this account, and the owner has the ability to withdraw money from it. However, I'm encountering an error: ...
0
votes
1
answer
27
views
If a transaction is created using subxt/polkadot-js and how to sign it using any crypto libraries and send it again using subxt/polkadot-js
I'm trying to create a poc to separate out the signing of transactions from the libraries such as subxt or polkadot-js. I was trying subxt and schnorrkel libs to create partial signed transaction and ...
1
vote
0
answers
59
views
My implementation wont let me batch more than 4 transfer calls
My implementation wont let me batch more than 4 transfers. Am I doing something wrong?
I know the code is a bit complex because its normally not in one func but i has to be in this way. I am suprised ...
1
vote
2
answers
25
views
Provide judgement on polkadot js
I'm trying to use my node's identity pallet via polkadot js. Generally that works well, but I do run into an issue when providing judgements.
This function requires an identity: H256 (Hash) value. ...
0
votes
1
answer
39
views
Kilt SDK import breaks types
after adding the kiltprotocol/sdk-js to my front-end, I get the following two errors when importing the kilt module.
Error 1:
Type 'Codec | Codec[]' is not assignable to type 'InjectedAccountWithMeta[]...
0
votes
0
answers
17
views
How to Handle Disconnections with WsProvider for Persistent Browser Tabs and Safari on IOS?
We're currently working on [Grill. chat] (https://grill.chat)and uses the WsProvider to establish a WebSocket connection with xSubsocial node. However, we are encountering an issue where the WebSocket ...
0
votes
0
answers
29
views
Error: createType(ExtrinsicSignature):: Unable to create Enum via index 108, in Ed25519, Sr25519, Ecdsa
I'm trying to use the Polkadot CLI to create an unsigned extrinsic, which I subsequently generate a signature for sign out of band using my custody provider. The Polkadot CLI has a useful tool for ...
3
votes
1
answer
29
views
subscriptions with parameters in polkadot.js api
I am using React+Typescript and trying to retrieve data from a struc using a query subscription. I first tried the following in order to check that I'm retrieving the right data:
api.query.rolesModule....
0
votes
1
answer
31
views
Uncaught (in promise) Error: Cannot convert 'InBlock' via asFinalized
I am trying to sign and send some transactions using the batch function.
Here are some code snippets for reproduction.
const nftMinting = async (item) => {
try {
let collection = 1
...
0
votes
1
answer
26
views
Where can I find the js code of polkadot pallet?
As we can see in polkadotjs, when we add pallet then we can see interaction interface as shown in image below. But how this code is generated? Where can I find the code?
2
votes
0
answers
32
views
Someone suggest me some resources of NFT Pallet frontend react implementation?
I am using nft-pallet for nft creation. I have implemented in substrate node. Now I wan't to write my own code not polkadotjs to create with nft using nft pallet using react frontend. Someone please ...
0
votes
0
answers
26
views
How to get the current session keys used by an active validator?
There are api.query.session.nextKeys and api.query.session.queuedKeys for obtaining the next session keys for a validator (doc).
But how do I query the current the session keys used by an active ...
1
vote
1
answer
22
views
When sending Transact XCM Instruction, how to specify the pallet which contains the extrinsic to execute on target parachain?
When sending Transact XCM Instruction from parachain A, how do I specify (or how does the xcm-executor know) the pallet / pallet id on the target Parachain B which contains the extrinsic to be ...
3
votes
1
answer
29
views
Estimated fees too high
Estimated fees for some extrinsics look significantly higher (4-10x) that the final used ones.
This example of a delegate call highlight this: https://polkadot.subscan.io/extrinsic/16420739-2 (see ...
1
vote
1
answer
45
views
How to programmatically execute xcm message from Patachain A to execute an extrinsic on Parachain B
I have a local relaychain setup with 2 parachains Parachain A and Parachain B .
I will like to execute an XCM message from Parachain A to execute an extrinsic on Parachain B using the Transact ...
1
vote
3
answers
45
views
How to call PSP22::approve function from Frontend
Any guidance on how to call my psp22 approve function from the front end ? This is currently how I'm doing it but it doesn't seem to give increased allowance (although its successful) :
import { ...
3
votes
1
answer
39
views
Custom RPC vs. runtime API
As a Substrate builder, I don't see any reason of still implementing custom RPCs as runtime API seems superior to me. So I was wondering about any arguments for still adding custom RPCs to the client.
...
2
votes
1
answer
34
views
I'm using Polkadot js api to fetch the westmint nft pallet collection and their details but i got an error it dosen't show me the instance id
I tried to figure out the collection id from the api i got an hex value but when i tried to convert that hex to numbers i got an undefined value here is my code
i think the hex value which is outside ...
2
votes
1
answer
31
views
Error with submitted preimage
I am attempting to note.preimage the following call data hash:
...
2
votes
1
answer
25
views
How to Recover Address from MasterPrivateKey in JS
I trying to make Signature using Polkadot.js without mnemonic in LedgerAddress.
import { hdLedger } from "@polkadot/util-crypto";
import { u8aToHex } from "@polkadot/util";
import ...
0
votes
0
answers
10
views
polkadot-apps build working, but failing to run
We have a forked apps repo and did an upstream merge recently. It is working fine when running yarn start, but whenever we try to build the code and use that index.html file its failing to run. There ...
0
votes
1
answer
38
views
Substrate-connect for solo-chains
I don't see any support for connecting via the substract-connect library for a sovereign chain. E.g. the addChain function has a dependency on the relay chain.
Is there some way to connect to a custom ...
2
votes
1
answer
53
views
api.createType does not work?
I would like to create a type called XcmVersionedMultiLocation. It can be imported using the following code:
import { XcmVersionedMultiLocation } from "@polkadot/types/lookup";
To create an ...
0
votes
2
answers
30
views
How to cleanup a failed ApiPromise after initialising
Currently trying to create a way to attempt a new ApiPromise .If a specific RPC is deemed to be down / unavailable
Code basically looks like this
const api = await ApiPromise.create({
...
0
votes
1
answer
21
views
How to get a list of voters per referenda through Polkadot JS?
I am trying to assemble a list of all voters on a referendum with their votes, etc. I need help on what storage pallet to call, I tried calling the functions on the convictionVoting pallet which is ...
0
votes
2
answers
42
views
duplicated sessionkey
In polkadot.js staking , when i put the session key, the result is "duplicated session key"
I use the command in SSH "echo '{"id":1,"jsonrpc":"2.0","...
5
votes
2
answers
51
views
How to query chainspec with @polkadot/api
In the documentation getChainProperties(https://polkadot.js.org/docs/api/examples/promise/chain-info/) is mentioned for getting the properties for a blockchain, but it contains very little amount of ...
2
votes
1
answer
38
views
validating node, how connet to polkadot.js
for running validate nodes, through set up, now i can see my node on the telemetry. but i dont know how to connect to polkadot.js.
polka wiki says
"You can generate your Session keys in the ...
3
votes
2
answers
46
views
How to perform chain state query for entries AND at a block hash?
I can do this to get all the structs in my storage:
let queryResult = await api.query.mypallet.mystorage.entries();
but I want this query AT a specific block hash:
let currentHeader = ...
4
votes
3
answers
61
views
Troubleshooting Polkadot.js Recognition of Prefunded Dev Accounts on a Network Using EthereumSignature
I've made some changes to my blockchain setup recently. I switched the signature over to EthereumSignature, which changed my AccountId to an H160 size. Thankfully, I can still use scripts to manage ...
4
votes
0
answers
31
views
Polkadot JS units for currency
I am implementing a pallet which interacts with pallet_balances via Currency trait. For some reason, when I call any operation on currency trait (like Slash on screen below), it is not aligned to ...
4
votes
3
answers
36
views
How to independently check in which block extrinsic got included?
The standard way to track extrinsics is:
api.tx.balances
.transfer(recipient, 123)
.signAndSend(sender, ({ status, events }) => {
if (status.isInBlock) {
// here we know that our tx ...
3
votes
0
answers
31
views
How to compare current date with a stored date in a Substrate blockchain module?
I'm working with a Substrate blockchain and have a structure with a field named end_date. I'd like to check if the current date is greater than end_date within a Substrate runtime module, but I'm ...
3
votes
0
answers
31
views
How to get runtime types in polkadotjs (typescript)
In subxt we can have Rust types directly from scale-encoded runtime metadata. Is the same possible in polkadotjs? Is there a "polkadots" which has typescript types automatically derived from ...
3
votes
1
answer
72
views
How to convert Account ID into Account Bytes in Hex using polkadot js?
I'm following this article about substrate keys. And I was unable to convert the account ID to account bytes in hex as it guides:
from this:
Account ID
...
2
votes
1
answer
91
views
How to Implement MaxEncodedLen Trait for Structs Containing Vec<u8> in Rust
i'm trying to create a blockchain runtime module using Substrate. I have defined a few data structures with the #[derive(MaxEncodedLen)] attribute, but I'm running into a problem when trying to ...
5
votes
1
answer
118
views
When is a transaction `retracted`?
PolkadotJS offers a status indication for a transaction receipt that is called isRetracted.
What does it mean and when does it occur?
6
votes
0
answers
62
views
Decompose complex types in JS
My overall goal is to build a generic extrinsic builder, just like the extrinsic tab from polkadot-js/apps. This code is very old and very hard to decipher unfortunately and I couldn't find any doc ...
4
votes
0
answers
65
views
Creating SignerPayload for PolkadotJS Extenstion: Unsupported extrinsic payload version 0
I am trying to create a SignerPayloadJSON from an encoded partial extrinsic in polkadotjs. The partial extrinsic has the following hex representation
...
3
votes
1
answer
59
views
Problem deploying smart contract on rococo
I have been following the public documentation of polkadot API to deploy contract: https://polkadot.js.org/docs/api-contract/start/code
but I'm getting error Uncaught (in promise) TypeError: code.tx....
4
votes
2
answers
44
views
How does the PolkadotApps get the lease period?
On the parachain auction page. IIUC, there isn't any on-chain storage to store these values. How can I get that?