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
356 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
345 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
  • 893
5 votes
1 answer
853 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
5 votes
2 answers
294 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
4 votes
2 answers
276 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
141 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
1 answer
131 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
8 votes
1 answer
129 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
365 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
  • 101
8 votes
1 answer
242 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
299 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
1 answer
180 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
  • 410
5 votes
2 answers
589 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
265 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
4 votes
2 answers
193 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 ...
Decentration's user avatar
  • 1,326
3 votes
1 answer
182 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
  • 893
3 votes
1 answer
32 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
116 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
3 answers
101 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
140 views

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

as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8) Im trying to invoke balanceOf() PSP22 ...
yonatan hornstein's user avatar
3 votes
1 answer
98 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
1 answer
206 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
2 votes
1 answer
222 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
138 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
  • 413
2 votes
1 answer
104 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
47 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....
Decentration's user avatar
  • 1,326
2 votes
1 answer
71 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
2 votes
1 answer
181 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
1 vote
1 answer
72 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
77 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
  • 131
1 vote
2 answers
114 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
3 answers
225 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-...
Decentration's user avatar
  • 1,326
1 vote
1 answer
113 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
1 vote
1 answer
158 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
3 answers
218 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
  • 929
1 vote
1 answer
82 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
136 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
2 answers
112 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
  • 7,705
1 vote
1 answer
93 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
  • 195
0 votes
1 answer
26 views

Auto-upload Contracts To UI OR Pre-Populate Dropzone In Modal For Adding Contracts on Polkadot-JS/apps

We are using a clone of the Polkadot-JS/apps. Our users will need to have several contracts loaded to the UI in order to use the apps. We want our users to be able to add an existing contract to their ...
KathrynColleen's user avatar
0 votes
3 answers
88 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
  • 47
0 votes
1 answer
97 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,148
0 votes
2 answers
121 views

Problem Connecting Digital Ocean RPC Node to Polkadot-JS (NGINX Configuration Problem?)

I have established an RPC node on a Digital Ocean droplet and configured NGINX and SSL according to the instructions at the polkadot wiki. Configurations below. Connecting on wss://koabd.rocks or wss:/...
KathrynColleen's user avatar
0 votes
1 answer
46 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,377
0 votes
1 answer
57 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
  • 342
0 votes
1 answer
85 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
  • 138