Questions tagged [polkadot-js]
Questions about the Polakdot JS API used to interact with Substrate based chains via JavaScript.
44
questions
2
votes
1
answer
296
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 ...
5
votes
1
answer
752
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 ...
4
votes
2
answers
269
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?
...
3
votes
1
answer
274
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 ...
2
votes
1
answer
121
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 ...
1
vote
1
answer
113
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 ...
8
votes
1
answer
277
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 ...
8
votes
1
answer
122
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 ...
7
votes
1
answer
180
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. ...
5
votes
2
answers
110
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 ...
5
votes
1
answer
129
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-...
5
votes
2
answers
503
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": ...
4
votes
2
answers
187
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 ...
4
votes
2
answers
162
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 ...
4
votes
2
answers
249
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?
3
votes
1
answer
81
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: ...
3
votes
2
answers
213
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 ...
3
votes
1
answer
164
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 ...
3
votes
1
answer
121
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 ...
2
votes
1
answer
88
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 ...
2
votes
1
answer
27
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 ...
2
votes
3
answers
84
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)
....
2
votes
1
answer
97
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 ...
2
votes
1
answer
154
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",
&...
2
votes
1
answer
151
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, ...
1
vote
1
answer
102
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 ...
1
vote
1
answer
65
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. ...
1
vote
1
answer
57
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 ...
1
vote
1
answer
30
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....
1
vote
2
answers
90
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?
1
vote
3
answers
116
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
...
1
vote
1
answer
80
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....
1
vote
3
answers
177
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-...
1
vote
1
answer
131
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 ...
1
vote
1
answer
91
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.
1
vote
2
answers
97
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 ...
1
vote
1
answer
70
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..?
1
vote
1
answer
62
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'
...
0
votes
1
answer
84
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 ...
0
votes
3
answers
82
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&...
0
votes
1
answer
45
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.
...
0
votes
1
answer
24
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 ...
0
votes
1
answer
41
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 ...
0
votes
1
answer
41
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 ...