Questions tagged [polkadot-js]
Questions about the Polkadot-JS API used to interact with Substrate-based chains using JavaScript.
512
questions
12
votes
1
answer
256
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
102
views
How to add parachain logo to polkadot.js.org/apps?
How to add parachain logo to left side menu polkadot.js.org ?
9
votes
1
answer
110
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 ...
9
votes
1
answer
99
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 ...
9
votes
1
answer
73
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
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 ...
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 ...
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. ...
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?
7
votes
1
answer
92
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", "...
7
votes
1
answer
159
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 ...
7
votes
1
answer
202
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
3
answers
336
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/...
6
votes
3
answers
119
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?
6
votes
2
answers
218
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 ...
6
votes
1
answer
67
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 ...
6
votes
1
answer
71
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....
6
votes
1
answer
289
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 ...
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-...
6
votes
1
answer
238
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
62
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 ...
6
votes
0
answers
153
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 ...
5
votes
2
answers
219
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
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": ...
5
votes
2
answers
108
views
Polkadot.js and Ledger device compatibility
I linked a new Ledger to the Polkadot.js wallet and transferred some refunded DOT tokens into this wallet. But when I opened up my Ledger Live again, the DOT account is showing a 0 balance. Then I ...
5
votes
1
answer
124
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
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 ...
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
87
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
135
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
109
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
1
answer
137
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 ...
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?
...
5
votes
2
answers
97
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
118
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?
5
votes
2
answers
150
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
1
answer
70
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 ...
5
votes
1
answer
151
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 ...
5
votes
2
answers
203
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
140
views
How to make runtime api available from polkadot js
I declared runtime api, implemented it in runtime, but i can't call my runtime api from polkadot.js. What i need to do to be able to call it?
Declaration:
sp_api::decl_runtime_apis! {
pub trait ...
5
votes
2
answers
126
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
2
answers
155
views
What is the best way to batch ~20 000 calls to a chain?
What should I choose between these two options:
utility.batch()
I can batch multiple calls into one call, so it avoids making too many calls, but I'm afraid this will exceed the size of the block if ...
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 ...
5
votes
1
answer
73
views
How to create pallet errors for sudo that show up on the Polkadot JS apps interface?
Repost from stackoverflow:
So I've been at my wits' end for quite some time regarding #[pallet::error] showing up on Polkadot JS apps interface when calling a fallible function from sudo. So as I've ...
5
votes
1
answer
103
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
2
answers
51
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 ...
5
votes
1
answer
40
views
How to access Polkadot/Kusama runtime types from polkadot.js api to work with the transactions arguments
With subxt is straight-forward as you can access the types by generating them using metadata and use them in your fn arguments but in polkadot.js is kinda not straight forward as where and how the ...
5
votes
1
answer
36
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 ...
5
votes
1
answer
42
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 === ...
4
votes
2
answers
108
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()
...