Questions tagged [polkadot-js]
Questions about the Polakdot JS API used to interact with Substrate based chains via JavaScript.
469
questions
11
votes
1
answer
119
views
How to upgrade the client?
I want to do a runtime upgrade but I got the same error as here
solution is :- If there are changes not only to the runtime but also to the node, then this issue is normally caused by upgrading the ...
10
votes
2
answers
113
views
Staking Election Failed (staking.StakingElectionFailed The election failed. No new era is planned. ) after adding EVM with NPOS(i.e BABE)
I have Added EVM pallet to my NPOS based Substrate chain but i am facing staking.StakingElectionFailed The election failed. No new era is planned. how to solve this issue.
I have implemented the NPOS ...
10
votes
1
answer
223
views
PolkadotJS how to properly setup api for custom RPC invocation
I'm playing around with custom RPC endpoints exposed from my substrate node, but I'm encountering an issue when trying to call it with polkadotjs. Initially, my endpoint only accepted a single ...
9
votes
1
answer
71
views
Incorrect display name for smart contracts numeric return types
When I deploy an ERC20 on Polkadot JS Apps, i can see that the return type of total_supply is u128, however according to the contract metadata it should display Balance.
Noticed also for ERC1155 ...
8
votes
1
answer
280
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
95
views
How to add parachain logo to polkadot.js.org/apps?
How to add parachain logo to left side menu polkadot.js.org ?
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
91
views
What are type bundles and versioned metadata?
I was exploring typegen for my node's custom types and came across these two concepts in the acala.js codebase in the type-definitions package (their use of a "types-bundle.json"), and ...
7
votes
1
answer
91
views
Can an account's transactions be front-run on Polkadot? If so, how?
Is it possible to reliably monitor an account and receive information about a transaction of that account before the transaction is InBlock and then front-run that transaction by issuing a ...
7
votes
1
answer
181
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. ...
7
votes
1
answer
66
views
getting Error's while adding pallet_evm to runtime " the trait bound `pallet_evm::Pallet<Runtime>: Callable<Runtime>` is not satisfied in `Call`"
I am trying to add Evm pallet to my substrate runtime i am using Polkadotv0.9.25 for both substrate and frontier but getting error of trait bound for almost every pallet.
error:- within Call, the ...
7
votes
1
answer
132
views
Unable to deploy EVM contract on Astar
I have cloned Astar and built it, after running the cloned Astar code i tried to deploy evm smart contract on it but it is showing Error error:evm.balanceLow. I have used SubWallet to create an evm ...
6
votes
1
answer
86
views
How to accurately add extrinsic balance transfer values
Is there a simpler way to add balance transfer values without converting them to BN or Unit value first? For example, say I want to add "0x00000000000000001bc16d674ec80000", "...
6
votes
1
answer
180
views
Babel loader issues with polkadotjs and create-react-app
We're working to update our dApp to node 16 and update the dev config to point to the latest polkadot dev config.
We are using customize-cra to customize the babel loaders which looks partially as:
...
6
votes
1
answer
135
views
How do I verify a signature signed using Polkadot.js app with rust code
I am trying to write a discord bot using rust/serenity to verify signature signed using polkadot.js app. I use schnorrkel crate, wrap the message in <Bytes>...</Bytes> and use the verify ...
6
votes
1
answer
231
views
Moonbeam Parachain staking
I have added parachain staking and moonbeam-orbiters of moonbeam in our project. When I test it, all the extrinsics are performing well except the staking part. I have gone through this https://docs....
6
votes
0
answers
32
views
How to connect to Polkadot Relay-Chain through the code of moonbeam parachain?
I want to connect polkadot relay chain but i'm not able to select keys for the customSpec generated by the binary of Moonbeam-Parachain. The customSpec is this->
{
"name": &...
5
votes
3
answers
260
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/...
5
votes
2
answers
195
views
How to find how many transactions are pending from address to be added to block?
In my application, I need to fire multiple transactions from same address, and want to create statusCheck() function, which will let me know how many transactions of total are still pending to be ...
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": ...
5
votes
1
answer
118
views
How to upload contract using a custom made frontend?
I am making a new UI for substrate based blockchain, and found the code here to upload a Smart Contract.
The code allows you to either upload metadata.json && cont.wasm files or a cont....
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 ...
5
votes
3
answers
107
views
How to track token issuance
How would I track the token issuance of a parachain, using either the polkadot api or on-chain data? Does anyone have a simple example?
5
votes
2
answers
171
views
What format is the block timestamp?
I'm using @polkadot-js to decode extrinsic data. The following method call returns a timestamp at a specific block, but I don't know how to parse this.
I tried assuming that it's a unix timestamp in ...
5
votes
1
answer
28
views
Using a JS Proxy around ApiPromise
I would like to use a standard JS Proxy around ApiPromise, basically to add my own fields to the object without having to extend it. I have some issues doing the following:
const proxied = new Proxy(
...
5
votes
1
answer
62
views
Substrate connect & JS API
This question came to the forefront after reading the question about the connect extension and the usage thereof on live networks.
From the comments it is apparent that I can use the JS API to connect ...
5
votes
1
answer
74
views
Two-way JS serlialise between hex and extrinsic object
I know that all the objects in the JS API has the toHex() function, so that would answer the first bit of my question - how to serialize when I have an extrinsic from getBlock().
However where I'm ...
5
votes
1
answer
123
views
How do I connect substrate frontend with backend on Digital Ocean?
I've launched several substrate nodes in several clouds, one of which is Digital Ocean. The telemetry at telemetry.polkadot.io works just fine, it shows all the nodes and block generated in the real-...
5
votes
2
answers
94
views
How to prevent Polkadot{.js} extension from injecting all addresses into the site's JavaScript context
By default the Polkadot{.js} extension injects all addresses that have been imported into the browser wallet when a connection is requested by a website.
In comparison, the Metamask extension on ...
5
votes
2
answers
89
views
Why can't I decode an extrinsic created with the contracts tab in Polkadot JS apps?
I am running the substrate-contracts-node and using the contracts UI to interact with it in Polkadot JS Apps. The contract call is failing when I try using the UI, although the same call works from a ...
5
votes
1
answer
174
views
How do we import a self-signed certificate for the Polkadot-JS electron app or AppImage?
According to https://wiki.polkadot.network/docs/maintain-wss#importing-the-certificate
One can visit the cloud instance on https and download the certificate and then proceed to connect to a websocket ...
5
votes
2
answers
119
views
How to use Polkadot.js API for governance proxy call correctly?
I am trying to create a JS code to be able to vote using proxy account that has been given democracy permissions to stash account, so I would be able to vote using just my mobile phone instead of ...
5
votes
2
answers
194
views
How to enable units for currencies in polkadot-js
Currently, polkadot-js doesn't allow me to select a unit when specifying balances in the Developer > Extrinsics section, which means that all balances must be specified in the smallest unit (10^12 ...
5
votes
2
answers
111
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
132
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
1
answer
67
views
PolkadotJS Apps shows wrong AccountId20 on Frontier Template Node
Frontier recently received support for Moonbeam's AccountId20:
https://github.com/paritytech/frontier/pull/1019
So now I'm trying to use this new feature on PolkadotJS Apps.
I'm running a Frontier ...
5
votes
0
answers
105
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 ...
4
votes
2
answers
88
views
How to load account address from polkadot extension?
I have following code so far.
import { useSubstrateState } from './../substrate-lib'
import { web3FromSource } from '@polkadot/extension-dapp'
const { api, currentAccount } = useSubstrateState()
...
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?
4
votes
1
answer
63
views
types bundle for kusama
While fetching blocks from kusama, I get the following message in the block range [1, 461692]:
Unable to map u16 to a lookup index
I suppose this has to do with the types being used in the old blocks....
4
votes
1
answer
106
views
PolkadotJS ALICE address differs
When I try to derive the Alice account with PolkadotJS I somehow end up with a different address than in the docs.
Here is the code:
const keyring = new (require('@polkadot/keyring').Keyring)();
let ...
4
votes
2
answers
190
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
1
answer
78
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 ...
4
votes
1
answer
139
views
Sign a transaction offline for Westend testnet and verification of the transaction
Could Polkadot experts execute the code below and advise me on the questions, please?
You just need to replace the code by your own Westend accounts and nonce.
import { construct, getRegistry, ...
4
votes
2
answers
270
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?
...
4
votes
2
answers
234
views
Events in Polkadot.js/api
I am trying to call api.events.staking.Withdrawn.is in polkadot.js/api.
Docs: https://polkadot.js.org/docs/substrate/events#withdrawnaccountid32-u128
Code sandbox: https://codesandbox.io/s/hardcore-...
4
votes
2
answers
60
views
failed decode in Kusama
I get the following error while trying to fetch block #1375921 on Kusama chain:
RPC-CORE: getBlock(hash?: BlockHash): SignedBlock:: createType(SignedBlock):: Struct:
failed on block: {"header&...
4
votes
1
answer
60
views
What is the Incomplete Execution error on parachain upgrade?
I have been upgrading my parachain many times over the last few days with no issue at all. I have been using Polkadotjs Apps for this also running on my local machine.
My process is that I use the ...
4
votes
1
answer
129
views
Best way to configure Webpack4 and @polkadot dependencies in a webworker?
I am in the process of updating a react-app from polkadot.js api: 6.9.2 -> 7.12.1. Following some advice in the docs: https://polkadot.js.org/docs/usage/FAQ/, I updated my customize-cra application ...
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 ...