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
3 votes
1 answer
494 views

To get the extrinsic data from the extrinsic Hash

When I submit a transation using the polakdot-js-api I get that the transaction is included in block number and I also receive the extrinsic hash ```*Tx included at block hash ...
kroos47's user avatar
  • 59
5 votes
1 answer
456 views

How to format balance?

I tried using @polkadot/util's formatBalance function to get the formatted balance of the account. But it doesn't make sense. I believe unit conversion is not working properly and I wonder what I am ...
Burak's user avatar
  • 903
5 votes
2 answers
341 views

Sudo option is missing

I just clone the Polkadot repo v0.9.20 and build. When I run the chain sudo option is not showing in developer section. Running chain on 127.0.0.1:9944. Can anyone please tell why this thing happen? ...
Deepak Chaudhary's user avatar
5 votes
1 answer
1k views

Custom RPCs not decorated

I added some custom RPC endpoints to a substrate blockchain, but when I connect to the node with a simple script it prints: API/INIT: RPC methods not decorated: ... The RPCs work, but don't show up ...
weichweich's user avatar
4 votes
2 answers
333 views

How to sign a message using ECDSA key pairs in Polkadot.js so it can be verified in the ink! contract

I want to build an ink! contract where some functions need to verify messages signed by the caller. In ink! contract there is a helper function named ink_env::ecdsa_recover(), which seems helpful in ...
Soptq's user avatar
  • 41
2 votes
1 answer
186 views

How to determine value for param num_slashing_spans for a withdrawUnbonded tx?

I'm having trouble determining values for param num_slashing_spans for api.tx.staking.withdrawUnbonded. I see that the most popular value is 0, but sometimes people also use 2 and 84. Is there any ...
ltqn's user avatar
  • 23
1 vote
3 answers
373 views

Connecting to a chain on `ws` localhost with polkadot.js app fails when running in brave browser

I know this question is more related to the usage of Brave browser, but the chance of getting a relevant answer would be less in brave forums where the general understanding of polkatot-js is less ...
Simson's user avatar
  • 1,166
1 vote
1 answer
156 views

how to confirm payment from specific address?

I am adding substrate based payment mechanism to my web app. App would provide substrate address to end user, where he/she will send required funds by some external means. Now I want my app to find ...
pravin k's user avatar
  • 111
9 votes
1 answer
456 views

How to get the balance of an account at a particular nonce using Polkadot.js API

I want get the balance of an account address at a particular nonce. I only know how to get the latest balance of an account address and its latest nonce (total number of transactions sent from that ...
Lee's user avatar
  • 111
8 votes
1 answer
145 views

How to setup and RPC call that accepts a u128 input?

I cannot seem to setup a RPC call that accepts a u128 param. I can input the following let u128Input = new BN("10") let output = await api.rpc.template.testRpc(u128Input); but get an error ...
drbh's user avatar
  • 83
8 votes
1 answer
353 views

How to estimate gas for ink contracts transactions for Weights V2?

For ink contracts with weight v2 it requires refTime and proofSize. For this we are first querying(dry run) the transaction method, getting gasRequired from query result and sending it to transaction. ...
Nikhil Ranjan's user avatar
7 votes
2 answers
367 views

How to decode ink smart contract call and event data?

I want to decode the contract call data and event data saved in a block. How can I do that?
Minh Mốc's user avatar
6 votes
3 answers
456 views

How to convert Public key (hex) to SS58 Address in JavaScript / Polkadot-JS?

I have a Public key (hex) and would like to convert it to an SS58 Address. What is the right function to use? I found the docs here with an code-sniped: https://substrate-developer-hub.github.io/docs/...
SiAlDev's user avatar
  • 91
6 votes
2 answers
237 views

What's a convenient way to look up a `DispatchError` in polkadot-js?

A DispatchError will refer to a pallet and a member of the pallet's Error enum by index: DispatchError: {"module":{"index":123,"error":456}} It's tiresome and error-...
mkl's user avatar
  • 420
5 votes
2 answers
151 views

Show custom RPCs/RuntimeAPIs in PolkadotJS UI

At the moment I try to figure out why PolkadotJS UI (https://polkadot.js.org/) is not able to show my custom RPC endpoints or runtime APIs. They are available in general and also available in the list ...
Janislav's user avatar
  • 319
5 votes
2 answers
751 views

How to decode extrinsic at json-RPC call's data(byte code)

I call json-RPC through the terminal and get the data as below. extrinsics is raw byte, but I'm using polkadot-js(SCALE codec?) to decode it. But I don't know which method to call. "block": ...
PaperFrog's user avatar
  • 495
4 votes
2 answers
237 views

How to decorate RPC correctly?

The rpc methods (showing in rpc_methods), are still not showing in their own area, after (attempting to) decorate the rpc. I have custom rpc on a substrate template. Here are the rpc_methods: I have ...
Ramsey - Decentration's user avatar
4 votes
1 answer
137 views

TS type generation - @polkadot/api

I've been trying to follow the documentation for generating types for @polkadot/api https://polkadot.js.org/docs/api/examples/promise/typegen/. However the generated files seem to be missing many ...
Jonathan Gray's user avatar
4 votes
2 answers
436 views

How to get historical substrate (extrinsic, events, etc) data using polkaDotJS API

PolkaDotJS API docs show to get extrinsic, events, etc data for a particular block. Is there a way to get all the extrinsic, events, etc data for the substrate network without having to get for each ...
John Otu's user avatar
  • 385
3 votes
1 answer
138 views

change consensus of substrate

I want to change my substrate chain consensus but I don't know how to set the new consensus in substrate. I want to set dops consensus for my substrate chain also please guide my for implement dpos in ...
Kianoush Dortaj's user avatar
3 votes
1 answer
44 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
3 votes
1 answer
158 views

Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts

As the title suggest, I'm trying to call PSP22 token contract and read balanceOf() function, but I get error that I'm passing a too big of a input (27 instead of 8) When I initializing the token it ...
yonatan hornstein's user avatar
3 votes
1 answer
268 views

Connection refused using --unsafe-rpc-external --unsafe-ws-external

I'm trying to connect to my local node using the --unsafe-rpc-external --unsafe-ws-external flags when running the node. I can connect to the node through a node.js script, but not from a browser ...
adrielvb's user avatar
3 votes
3 answers
127 views

Different representation of the same address between polkadot-js and an explorer

I am trying to create an address for Kusama. Here is my code: const seed = bip39.mnemonicToSeedSync(WALLET_MNEMONIC, WALLET_PASSWORD); const privateKeyBuffer = bip32 .fromSeed(seed) ....
kamaci's user avatar
  • 161
3 votes
1 answer
204 views

Can't request to my Custom RPC with an Enum

I'm trying to create a custom RPC for my pallet. I've followed Substrate Recipes (I know it's outdated but helped a lot) and pallet_transaction for Runtime API and RPC. My first RPC, profile_getSum, ...
Burak's user avatar
  • 903
3 votes
1 answer
127 views

getBlock - Unable to catch some transactions

when I run getBlock function as followed const signedBlock = await api.derived.chain.getBlock(blockhash) I can fetch data from this blockhash: ...
korimusk's user avatar
3 votes
2 answers
171 views

What are the set cli commands to stake on a validator node?

In this video Joe Petrowski demonstrates a command which allows us to set a stake and also choose a reward destination. But unfortunately some of the command gets obscured by their video picture. As I'...
Purple_Turtle's user avatar
2 votes
1 answer
175 views

Informing polkadot/api about additional signed extensions

Polkadot/api has a way to detail signed extensions and I want to understand (so I can use it for our own custom signed extension) what the extrinsic and payload parameters map to. Here's an example ...
Wil W's user avatar
  • 433
2 votes
1 answer
58 views

How to produce empty paramter in an Option?

In the screenshot below the OptionSelect is disabled, which produces info of an array of accounts rather than just one single. How do you replicate this option when curating a call? Using api.query....
Ramsey - Decentration's user avatar
2 votes
1 answer
258 views

How to decode events help on substrate using polkadot.js?

I have a base smart contract in rust with package manager cargo. In that smart contract I have some events which I'm emitting while function calling. For listing that events I have a service in java ...
Puneet Jindal's user avatar
2 votes
1 answer
120 views

How to write a custom query for storage?

When you declare a storage say pub type Something<T> = StorageValue<_, u32>; We get query function "something". But I want to write some specific functions that reads storage ...
Amiya Behera's user avatar
2 votes
1 answer
238 views

How do you resolve missing type errors in the @polkadot/api v7.x.x packages?

Upgrading from: // package.json "@polkadot/api": "^6.7.2", "@polkadot/types": "^6.7.2", to: // package.json "@polkadot/api": "^7.7.1", &...
tarrball's user avatar
  • 225
2 votes
1 answer
85 views

How to create a tuple type using polkadot.js api

I am trying to create a tuple. I know we can create an enum by defining the type as MyEnum: { _enum: { 'account': String, 'accountId': 'u128' ...
Emmanuel Thomas's user avatar
1 vote
1 answer
140 views

How do I use the AccountId20 and EthereumSignature Signer with polkadot.js.org? [duplicate]

I'm trying to get a better understanding of Frontier, and thus I'm reimplementing the frontier node template over the generic substrate node template. Unfortunately I'm pretty much stuck at step 1. ...
Farcaller's user avatar
  • 148
1 vote
1 answer
147 views

Invalid Transaction: Transaction has a bad signature - Ledger signature into tx

I am attempting to submit a transaction using Polkadot JS API and a signature that has been signed by Ledger. Upon passing it to send I get the Invalid Transaction: Transaction has a bad signature ...
Ross's user avatar
  • 141
1 vote
2 answers
159 views

How do I get the code hash of a smart contract using Polkadot{.js} API?

I know polkadot{.js} has an API to access contract storage here: https://polkadot.js.org/docs/substrate/storage#contracts How do I get the code hash via the account?
Bruno's user avatar
  • 8,260
1 vote
1 answer
173 views

How to provide unchecked weight to a call using Polkadot.js?

Unfortunately, I could not find how to add unchecked weight to a call via Polkadot.js, e.g. within signAndSend or when preparing the unsigned extrinsic. Even in the cookbook example for runtime ...
William Freudenberger's user avatar
1 vote
1 answer
46 views

How can you use Polkadot JS API to Create an XCM Reserve Transfer Assets? (XCM V2)

I am trying to create a reserve transfer assets call from a relay chain like Kusama to a Parachain. To do this, I need to: connect to the relay chain with Polkadot JS API construct the XCM types ...
Shawn Tabrizi's user avatar
  • 15.9k
1 vote
2 answers
140 views

How to use command line to register Parachain locally

Regarding this tutorial "Connect a local parachain": https://docs.substrate.io/tutorials/connect-other-chains/local-parachain/, it requires using GUI in a browser to do Parachain ...
Russo's user avatar
  • 1,193
1 vote
1 answer
82 views

`UnknownTransaction::CannotLookup` error on each extrinsic

I've implemented unified accounts in a NPoS consensus-based substrate chain, and modified the polkadot-js/apps accordingly as well. The transactions through metamask go through successfully, but I'm ...
Discardo's user avatar
  • 424
1 vote
3 answers
306 views

Docker container...-p 9944:9944 running Node Template not working on polkadot js apps

I'm trying to run a substrate node through docker container but i am not able to with this command: docker run -p 9944:9944 -p 30333:30333 -p 9933:9933 -p 9615:9615 docker.io/decentration/supersig-...
Ramsey - Decentration's user avatar
1 vote
1 answer
112 views

Unable to decode contract event: Unable to find event [closed]

Ive got this error on my console although transaction was succeeded. what causes this error..?
Steve's user avatar
  • 83
1 vote
1 answer
125 views

How to use api.events.staking.Rewarded.is to get nominator reward?

How to use api.events.staking.Rewarded.is to get reward? Like this: let event:IEventLike={ index:9281, method:"staking", section:"rewarded", }; const nominatorReward = api....
Rose's user avatar
  • 305
1 vote
3 answers
96 views

I can't open a HRMP channel between the parachains

I am testing XCM between parachain 2000 and parachain 2001 while referencing this link, How to open HRMP channels between parachains?. But I couldn't open a new HRMP channel, I faced the "Barrier&...
TinyDev's user avatar
  • 57
1 vote
1 answer
159 views

Using polkadot.js api, how can we list the members of a Kusama nomination pool?

According to the documentation, api.query.nominationPools.poolMembers should yield details about pool members. The result should be a Map so we should be able to iterate the .entries / .keys. (async ()...
DerekC's user avatar
  • 205
1 vote
1 answer
105 views

How to get a list of all the smart contract account ids and WASM blobs on a parachain

I would like to figure out how to get a list of all the smart contracts account ids and WASM blobs that have been uploaded to a specific parachain, ideally into python using the substrate interface. ...
Roger J Bos CFA's user avatar
1 vote
1 answer
224 views

Polkadot.js: How do I fetch all rewards paid to a specific nominator that resulted from a specific validator?

I have tried using api/packages/api-derive/src/staking/erasRewards.ts, but I do not understand what titrates the number of eras being shown. Also, whose rewards am I looking at? All rewards in that ...
Teo's user avatar
  • 37
1 vote
1 answer
149 views

How do I connect to an archive node with polkadot.js api?

Is there a list of archive nodes for polkadot/kusama/parachains? I'm trying to fetch all historical events in order to visualize staking rewards for nominators and validators.
Teo's user avatar
  • 37
0 votes
1 answer
101 views

`total_supply` function return value on erc20(psp22)

I am using erc20(psp22) smart contract to create fungible token. Contract successfully compiled and deployed. While I was deploying, I added initial_supply: Balance as 2. I tried to read ...
Ganesh11's user avatar
  • 1,207
0 votes
1 answer
53 views

How do we resolve the InvalidScheduleVersion error?

From the contracts pallet: /// A new schedule must have a greater version than the current one. InvalidScheduleVersion, The context of this error is sending batch transactions from ...
forgetso's user avatar
  • 1,482