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 ...
1
vote
2
answers
50
views
How to get event args values from contracts::contractemitted data?
I am using
const decodedEvent = Abi.decodeEvent(Uint8Array.from(Buffer.from("00000064a7b3b6e00d000000000000000000000000000000000000000000000000", 'hex')))
(...
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
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: ...
3
votes
2
answers
97
views
I'm getting some issue during storage migration
I'm trying to trigger the storage migration on polkadot UI for our parachain. I'm trying different types to do this but getting some issues:
Type 1 : If I simply upload the wasm file from sudo > ...
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","...
2
votes
1
answer
3k
views
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
Prior to cloning the substrate-front-end-template repo with tag "monthly-2022-02" I installed the following since I was building it from a Dockerfile using pre-built Docker image node:...
0
votes
1
answer
27
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
61
views
How to fix "module group is private" error when using frame-support-procedural-tools v3.0.0?
I'm trying to use orml-tokens in my Substrate project and encountered the following error:
error[E0603]: module `group` is private
--> /home/kianoush/.cargo/registry/src/github.com-...
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 ...
1
vote
2
answers
408
views
Transaction would exhaust the block limits error when calling a smart contract from Polkadot JS API
I'm trying to call a smart contract using the Polkadot JS API (like here). The contract function is really simple, it takes 2 strings: a key and a value as input parameters, then adds the key, value ...
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 ...
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 ...
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
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. ...
5
votes
2
answers
140
views
How to make runtime api available from polkadot js
I declared runtime api, implemented it in runtime, but i can't call my runtime api from polkadot.js. What i need to do to be able to call it?
Declaration:
sp_api::decl_runtime_apis! {
pub trait ...
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).
...
2
votes
1
answer
94
views
How can I decode this error message {"ok":{"flags":["Revert"],"data":"0x000110"}}?
I'm using polkadotjs to call my ink! smart contracts and I seem to be having trouble with calls that require parameters. For the call below I am getting the revert flag {"ok":{"flags&...
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 ...
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[]...
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
1
answer
25
views
How to get history of the native coin total issuance through API - Say DOT
How can one download the history of a native coin total issuance, via an API - Say DOT?
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 ...
1
vote
1
answer
45
views
Is there any way to get the validators signatures of the finalized blocks in substrate based chains?
I need the signatures of the validators who have signed on the produced and finalized blocks.
For example, In cosmos-SDK based blockchains blocks contains the signatures(and validators addresses) of ...
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 ...
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
1
answer
81
views
Can't vote from ledger using a hardware wallet?
I tried to vote from a ledger kusama account on polkadot js and I get Raw data signing is not supported for hardware wallets. Is this a limitation of the zondax ledger app or a polkadot-js limitation?
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
...
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 ...
1
vote
1
answer
75
views
How to get the payload from a polkadot-js transaction
I'm wondering what are the possible ways to extract the payload from a polkadot-js transaction.
So far the only way seems to be to define a custom signer that implements the Signer interface and then ...
2
votes
1
answer
66
views
How to use the polkadot/dev project template
I'm trying to convert my project over to a structure similar to the @polkadotjs repositories, but I'm finding the dev template provided a bit difficult to parse. Specifically:
How do I use this ...
1
vote
1
answer
53
views
How can I represent a polkadotjs type for a custom generic Enum?
I'm uncertain how I can structure the generic variant of a polkadotjs type for an on-chain Enum that looks sort of like this:
#[derive(TypeInfo, Debug, Clone, Encode, Decode, PartialEq)]
pub enum ...
3
votes
1
answer
43
views
How can I sign and execute transactions using custom origin(20 bytes address) in PolkadotJS
I have a pallet which ensures a particular custom origin of H160(20 bytes). Actually, this pallet is to ensure that the Origin is that of an ethereum address(20 bytes).
I am therefore writing ...
5
votes
1
answer
42
views
How do I get the currently logged address in front end template?
What I´m trying to do is to condition some option/modal to be shown in the screen depending on the logged user/account being the owner or not so to have something similar to:
accountPair.address === ...
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 ...
4
votes
1
answer
111
views
In-browser signing of payload generated with subxt
I am generating a partial unsigned extrinsic via subxt however cannot figure how to how to sign it using the polkadot.js api. For example:
#[subxt::subxt(runtime_metadata_path = "...
1
vote
2
answers
689
views
API-WS: disconnected from ws://127.0.0.1:9946: 1006:: Abnormal Closure
I'm trying to connect local node running on my pc using polkadot.js library in react.js(browser). I'm pasting my code in below snippet and error that I'm facing in chrome console
Code
// **************...
1
vote
1
answer
30
views
Resolving duplicate polkadot dependencies polkadot typescript sdk
I am currently using the polkadot sdk in my typescript project and while I was attempting to upgrade their versions, I deleted my yarn.lock file and reran yarn install but now I get this when I try ...
2
votes
2
answers
142
views
Update Runtime sudo transaction exhausted (Substrate)
I am trying to reimplement one of the Substrate tutorials:
https://docs.substrate.io/tutorials/get-started/upgrade-a-running-network/
But I am stuck with an issue - where it says to do Scheduler -> ...
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 { ...
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 ...
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 ...
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
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.
...