Questions tagged [polkadot-js]
Questions about the Polkadot-JS API used to interact with Substrate-based chains using JavaScript.
82
questions with no upvoted or accepted answers
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 ...
6
votes
0
answers
153
views
How to use the default Substrate CLI rpc-cors values without using rpc-cors=all for a Collator node and connect from Polkadot.js Apps
I want to be able to connect a collator node using https://polkadot.js.org/apps that is based on the substrate-parachain-template using branch 'polkadot-v0.9.18' and is being run as a parachain in ...
5
votes
1
answer
36
views
How to use @polkadot/react-components? version issue
I have tried to use @polkadot/react-componentsin React project
Here, AddressInfo component component is from @polkadot/react-components
When I try to use this component, I got this issue
I'd really ...
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 === ...
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
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
...
4
votes
1
answer
28
views
Why doesn't getMetadata show my callable methods as extrinsics in Substrate-node-template
When running Substrate-node-template - basically the Kitties - and with a callable eg create_kitty() as a dispatchableResult in the call pallet, what I assume to be an extrinsic in the metadata, this ...
4
votes
0
answers
155
views
api.call.transactionPaymentApi.queryInfo returns partial fee 0
With the update to the Polkadot-JS api depreciating rpc.payment.queryInfo in favor for api.call.transactionPaymentApi.queryInfo I am currently trying to migrate my code over. However I used to get the ...
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
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 ...
3
votes
0
answers
43
views
Where to add the Custom RPC types in polkadot-js/apps directory?
In the Custom RPC types docs it explains how to create the types within the API promise, but it doesn't explain where to add it within the polkadot-js/apps repo, which is understandable because the ...
3
votes
0
answers
43
views
Does callback get called when extrinsic is in block/finalized when the transaction is retracted?
In some cases the transaction I am signing and sending gets retracted, but its my impression that they are usually included in a future block.
When using polkadot js with the promise api, if the ...
3
votes
0
answers
65
views
Polkadot-JS API not reflecting changes on explorer or chain in local development
So i created a simple frame pallet with an extrinsic. I called this extrinsic from the local explorer at 127.0.0.1:9944 and everything worked and events were generated. But calling it from the ...
3
votes
0
answers
87
views
Custom typegen and using ApiPromise: Property 'unwrap' does not exist on type 'Codec'
It seems there is a mismatch between autocomplete suggestion return types from an ApiPromise instance and the actual returned type.
I am using "@polkadot/api": "8.1.1". I am ...
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 ...
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 ...
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&...
2
votes
0
answers
42
views
How to create a preimage which is the batch of other preimages?
I am wondering whether, and if so how, it is possible to submit a preimage which batches over other preimages, e.g.
const pre1= '0x09401eb25e90bf587fbde8d2a9be8af5ac0f3187f02f4e9e9f1f178b0314ebe5';
...
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
0
answers
61
views
Fuzzing Polkadot produces Invalid Signature after chaos is injected
I'm using Polkadot version 0.9.37-08b1c09ca46, across 4 Nodes - Alice, Bob, Charlie, Dave, in a local testnet environment. I have a period of network chaos applied, and then moments of stabilized '...
2
votes
1
answer
40
views
Is there a .into_sub_account_truncating equivalent for Javascript?
In rust I use:
.into_sub_account_truncating()
Is there a Javascript equivalent?
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:...
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
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
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
1
answer
39
views
Frontier template using sr25519 - polkajsapi
I just cloned frontier and modified the code for using H256 address following this
These are my changes in runtime/src/lib.rs:
pub type Signature = MultiSignature;
impl pallet_evm::Config for Runtime ...
1
vote
0
answers
61
views
How to calculate claimable rewards from dApp Staking on Astar and Shibuya across multiple eras and multiple dApps?
Hi~ I have some questions about the developer staking process.
I am using polkadot-api, developer staking part on shibuya-network.
At portal.astar.network, I can see staking info on the dApp Staking ...
1
vote
0
answers
20
views
What's the process to auto-generate `typesBundle.ts` in polkadot-js/apps?
Attempting to test some RPCs in development for a new pallet in Frequency, and trying to get them to show up in the Polkadot-JS UI running locally. I finally hit upon manually adding them to apps-...
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 ...
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 ...
1
vote
0
answers
37
views
PolkadotJS system and storage events are not being decoded and shown properly
I found a perhaps similar question here : Polkadot Explorer: decode storage system.events
We are running a custom parachain with frontier on a local testnet and while the transactions go through fine,...
1
vote
0
answers
22
views
How to show dropdown in PolkadotJS after selecting an item for extrinsic?
First of all I apologise in advance for asking this weird question. I am not sure if this is the right forum.
I have a scenario, where I have a data structure and storage like this:
#[derive(PartialEq,...
1
vote
1
answer
42
views
Use polkadot-v0.9.33 or hight verison bianry launch local parachain onborading fails
Using the ts code to call the parasSudoWrapper.sudoScheduleParaInitialize interface to register the parachain locally, the parachain has not produced blocks.. It is only a parathread found in the ...
1
vote
0
answers
32
views
Subscribe via json-rpc has no response
I don't get any response from json-rpc subscription.
It seems I need a type paramater, but the provider.subscribe() method does not document the type parameter. (I checked the js, java and python code,...
1
vote
0
answers
59
views
Use state call to query from custom Runtime Api, Balance in frontend is not equal to Balance in Runtime
Background
Our front end use state call to query custom RuntimeApi of our solo chain.
We try to use state call to replace custom rpcs.
Definition
Balance is our chain is u128.
RuntimeApi Definition
...
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 ...
1
vote
1
answer
30
views
How can I tell which validator is being bonded to for a given bonding extrinsic?
I would like to extract the validator that a given nominator is bonding? Is this possible given the extrinsic or should it be done some other way?
Here is my code:
const { ApiPromise, WsProvider } = ...
1
vote
0
answers
22
views
How did kusama and Polkadot integrated their respective ledger nano app via Polkadot ui?
Polkadot and kusama respectively have integrated their platform with ledger hardware wallet. After reading documentation I came to know that integrating a blockchain with ledger requires a nano app ...
1
vote
0
answers
2k
views
error TS2742: The inferred type of X cannot be named without a reference to
I am building simple SDK for Polkadot Api calls. I am running into following issue trying to build it:
error TS2742: The inferred type of 'closeChannel' cannot be named without a reference to '.pnpm/@...
1
vote
1
answer
76
views
Subscribe to all storage
Reading through this: https://polkadot.js.org/docs/api/start/api.query.multi/
It states "It should be trivially extendable to subscribe to the validators, track which one have entered or left&...
1
vote
0
answers
90
views
Why is it that the signature created using polkadot api is valid, but verifying that signature using substrate library is invalid?
The js code uses polkadot api, util-crypto and extension-dap
const { signature } = await signRaw({
address: account.address,
data: payload,
type: 'bytes'
});
// ...
1
vote
0
answers
49
views
Get reward amount in polkadot.js/api
I want to get reward for specific address in polkadot.js/api.
Especially for kusama.
Is polkadot.js providing such api to get reward for specific validator address?
also for specific block height?
1
vote
0
answers
31
views
Can not transfer balance in polkadot.js.org?
I start running development node, and try to test about transfer balance in polkadot.js.org
Problem: Make Transfer button only hidden, not show
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
0
answers
42
views
ChainBridge: how to show transferred amount from ERC20 to Substrate parachain?
after following the tutorial[https://chainbridge.chainsafe.io/local/] of running Chainbridge locally,
I can send 1 Substrate Native Token to ERC20
But when I sent 1, 100, 1000000, even ...
1
vote
0
answers
48
views
Error making .multi subscription call (Kitties Tutorial)
The error I see in the browser console is:
VEC: Unable to decode on index 0 createType(Lookup9):: Expected at least 32 bytes (256 bits), found 16 bytes
Offending code snippet (from Kitties.js):
// ...
1
vote
0
answers
39
views
Read Token Contract Information
I would like to read contract information(especially name, symbol, decimal, owner) from token contracts like shown here: https://moonbeam.moonscan.io/token/0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b#...
1
vote
0
answers
18
views
Why after passing more than 24 hours some tips close button on Polkadot js are still grey/disabled?
After a treasury tip receives "half + 1" tips from the councils, It goes to the countdown period. I run api.consts.tips.tipCountdown on Polkadot an get 14,400, which should be in blocks! If ...
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 ...