Skip to main content

Questions tagged [polkadot-js]

Questions about the Polkadot-JS API used to interact with Substrate-based chains using JavaScript.

Filter by
Sorted by
Tagged with
0 votes
1 answer
35 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?
go11li's user avatar
  • 1,241
2 votes
0 answers
46 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 ...
go11li's user avatar
  • 1,241
2 votes
1 answer
108 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 ...
btwiuse's user avatar
  • 291
3 votes
1 answer
43 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 ...
Julien Eluard's user avatar
2 votes
1 answer
64 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 ...
Neo's user avatar
  • 323
1 vote
3 answers
78 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 { ...
0xD1x0n's user avatar
  • 119
3 votes
1 answer
105 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. ...
0x5hmoo's user avatar
  • 189
2 votes
1 answer
79 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 ...
Ashutosh singh's user avatar
2 votes
1 answer
66 views

Error with submitted preimage

I am attempting to note.preimage the following call data hash: ...
Paradox - ParaNodes.io's user avatar
2 votes
1 answer
48 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 ...
Albert's user avatar
  • 21
0 votes
0 answers
15 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 ...
kroos47's user avatar
  • 59
0 votes
1 answer
56 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 ...
Justin Frevert's user avatar
2 votes
1 answer
82 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 ...
Michal Danco's user avatar
1 vote
2 answers
58 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({ ...
Joon's user avatar
  • 23
0 votes
1 answer
55 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 ...
user4394's user avatar
0 votes
2 answers
74 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","...
jay p's user avatar
  • 61
6 votes
2 answers
120 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 ...
Szegoo's user avatar
  • 667
2 votes
1 answer
61 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 don't know how to connect to polkadot.js. polka wiki says "You can generate your Session keys in the ...
jay p's user avatar
  • 61
3 votes
2 answers
76 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 = ...
Robert La Ferla's user avatar
4 votes
3 answers
82 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 ...
ALeSD's user avatar
  • 499
4 votes
0 answers
48 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 ...
Klapeyron's user avatar
  • 136
4 votes
3 answers
85 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 ...
Mexke's user avatar
  • 55
3 votes
0 answers
37 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 ...
Mr Coder's user avatar
  • 923
3 votes
0 answers
45 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 ...
Hugo Trentesaux's user avatar
4 votes
1 answer
207 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 ...
Xavier's user avatar
  • 415
2 votes
1 answer
100 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 ...
Mr Coder's user avatar
  • 923
5 votes
1 answer
163 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?
Oliver Tale-Yazdi's user avatar
6 votes
0 answers
74 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 ...
Tbaut's user avatar
  • 253
4 votes
1 answer
133 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 ...
Tadeo's user avatar
  • 61
3 votes
1 answer
82 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....
Nikola Bozin's user avatar
4 votes
2 answers
59 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?
AurevoirXavier's user avatar
  • 10.6k
5 votes
1 answer
48 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 ...
Christian Ramos's user avatar
4 votes
1 answer
39 views

Listen to balance changes wrong after transfer token

I'm facing an issue. I used a query subscription to listen and update the free balance on UI. But I don't know why, when I log free in callback, they always return a balance of receiver and then a ...
Tung Le Xuan's user avatar
3 votes
1 answer
38 views

Expose a custom `pub fn` from my pallet to frontend via polkadot.js API

I have a pallet that does some light calculation on one or more storage items (GasReserve and IdleFunds below) or wraps some internal functionality. E.g. impl<T: Config> Pallet<T> { ...
Garandor's user avatar
  • 121
2 votes
1 answer
84 views

I Can't Generate The right AccountId from Ethereum(H160) Address

I am writing a test to test evm contract instantiation using polkadot api. I get to derive the evm account like this: const alice = keyring.addFromUri('//Alice', { name: 'Alice default' }); const ...
dharjeezy's user avatar
  • 419
2 votes
1 answer
73 views

Polkadot.Js not showing identities of stashes on parachain rpc server

We are running public relaychain rpc endpoints and are further deploying polkadot-parachain endpoints, starting with statemine/statemint/westmint. Everything works but when using our endpoints in ...
stakeworld's user avatar
3 votes
1 answer
320 views

Polkadot.JS API / Reconnect

At times when using Polkadot.JS/Api connections would either timeout or become disconnected from the provider. When this happens the app crashes and exits. Is there any native setting to reconnect ...
Paradox - ParaNodes.io's user avatar
1 vote
1 answer
19 views

Implementing Stacking and Creating a Council in a Local Testnet

how we can implement stacking and made council in local testnet ? Thanks in Advance,
support's user avatar
  • 135
1 vote
1 answer
47 views

How to create address book?

I'm making a wallet that has an address book / contacts feature so that it's easier and faster for users to send balances to other users. Is storing the address book / contacts in the network is a ...
Pix Youtube's user avatar
1 vote
1 answer
34 views

How to send data to custom network?

is there any simple example to send data to network? like name, email, phone, address (which is made keyring), and address, etc
Pix Youtube's user avatar
4 votes
1 answer
181 views

how to get metadata as a `0x${string}` type

Hello guys i am trying to get the metadata as a 0x${string} type. I am calling the api endpoint state_getMetadata with await api.rpc.state.getMetadata() however this returns an object of Metadata and ...
Sven's user avatar
  • 51
5 votes
1 answer
46 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 === ...
Xavier's user avatar
  • 415
3 votes
1 answer
51 views

RuntimeVersion in SignedBlock - polkadot.js

when I make a call to api.rpc.chain.getBlock , I see that there is a call to chain_getHeader and state_getRuntimeVersion before the block is fetched. But, runtimeVersion does not get stored in the ...
Naveen's user avatar
  • 273
2 votes
1 answer
44 views

Output null when using ContractPromise for ink! v4 smart contract

I create a smart contract using ink! v4.2 and deploy it using contracts-ui.substrate.io Then in my front (which uses @polkadot/api-contract: 10.7.2, @polkadot/api: 10.7.2) I run this code: await ...
cris.sol's user avatar
  • 131
3 votes
1 answer
51 views

Get extrinsic fee using Polkadot.js/api

I want to get extrinsic fee using polkadot.js/api. I am checking kusama chain. https://kusama.subscan.io/extrinsic/17981827-3 I need to get 0.00053835621 fee from above extrinsic. Which api can I use ...
Heindrick's user avatar
  • 183
4 votes
1 answer
88 views

Extra calls to state_getRuntimeVersion with polkadot.js

Does any of these methods make a call to state_getRuntimeVersion internally? api.rpc.chain.getHeader api.rpc.chain.getBlockHash api.rpc.chain.getBlock api.rpc.state.getStorage because, I see double ...
Naveen's user avatar
  • 273
3 votes
1 answer
71 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 ...
dharjeezy's user avatar
  • 419
3 votes
1 answer
202 views

How to encode an extrinsic for RPC from a web client?

I need to programmatically pack an extrinsic for an RPC, I believe I'm looking for the following front-end functionality: extract relevant indices from the Metadata fill the extrinsic parameters ...
Yury Yukhananov's user avatar
3 votes
1 answer
37 views

Is there a way to render all values of a storage in drop down through Polkadot JS UI?

I have a scenario where I have to enter all values of a storage in drop down through Polkadot JS UI. Suppose I have a pallet TestPallet and an extrinsic rate. There are two storage Items and Rating. ...
Boleng's user avatar
  • 523
3 votes
1 answer
76 views

Can I use event data from previous calls in a batch?

Considering the following scenario, is it possible to execute all calls in a batch and therefore sign only once using utility.batchAll in polkadot.js? Create PureProxy from account A Assign account X ...
Andreea Eftene's user avatar

1 2
3
4 5
12