Questions tagged [polkadot-js]
Questions about the Polkadot-JS API used to interact with Substrate-based chains using JavaScript.
535
questions
3
votes
1
answer
55
views
Custom RPC vs. runtime API
As a Substrate builder, I don't see any reason of still implementing custom RPCs as runtime API seems superior to me. So I was wondering about any arguments for still adding custom RPCs to the client.
...
2
votes
1
answer
48
views
I'm using Polkadot js api to fetch the westmint nft pallet collection and their details but i got an error it dosen't show me the instance id
I tried to figure out the collection id from the api i got an hex value but when i tried to convert that hex to numbers i got an undefined value here is my code
i think the hex value which is outside ...
2
votes
1
answer
43
views
Error with submitted preimage
I am attempting to note.preimage the following call data hash:
...
2
votes
1
answer
27
views
How to Recover Address from MasterPrivateKey in JS
I trying to make Signature using Polkadot.js without mnemonic in LedgerAddress.
import { hdLedger } from "@polkadot/util-crypto";
import { u8aToHex } from "@polkadot/util";
import ...
0
votes
0
answers
12
views
polkadot-apps build working, but failing to run
We have a forked apps repo and did an upstream merge recently. It is working fine when running yarn start, but whenever we try to build the code and use that index.html file its failing to run. There ...
0
votes
1
answer
42
views
Substrate-connect for solo-chains
I don't see any support for connecting via the substract-connect library for a sovereign chain. E.g. the addChain function has a dependency on the relay chain.
Is there some way to connect to a custom ...
2
votes
1
answer
70
views
api.createType does not work?
I would like to create a type called XcmVersionedMultiLocation. It can be imported using the following code:
import { XcmVersionedMultiLocation } from "@polkadot/types/lookup";
To create an ...
0
votes
2
answers
37
views
How to cleanup a failed ApiPromise after initialising
Currently trying to create a way to attempt a new ApiPromise .If a specific RPC is deemed to be down / unavailable
Code basically looks like this
const api = await ApiPromise.create({
...
0
votes
1
answer
32
views
How to get a list of voters per referenda through Polkadot JS?
I am trying to assemble a list of all voters on a referendum with their votes, etc. I need help on what storage pallet to call, I tried calling the functions on the convictionVoting pallet which is ...
0
votes
2
answers
49
views
duplicated sessionkey
In polkadot.js staking , when i put the session key, the result is "duplicated session key"
I use the command in SSH "echo '{"id":1,"jsonrpc":"2.0","...
5
votes
3
answers
77
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 ...
2
votes
1
answer
54
views
Validating node, how connet to polkadot.js
For running validate nodes, through set up, now i can see my node on the telemetry. but I don't know how to connect to polkadot.js.
polka wiki says
"You can generate your Session keys in the ...
3
votes
2
answers
54
views
How to perform chain state query for entries AND at a block hash?
I can do this to get all the structs in my storage:
let queryResult = await api.query.mypallet.mystorage.entries();
but I want this query AT a specific block hash:
let currentHeader = ...
4
votes
3
answers
69
views
Troubleshooting Polkadot.js Recognition of Prefunded Dev Accounts on a Network Using EthereumSignature
I've made some changes to my blockchain setup recently. I switched the signature over to EthereumSignature, which changed my AccountId to an H160 size. Thankfully, I can still use scripts to manage ...
4
votes
0
answers
37
views
Polkadot JS units for currency
I am implementing a pallet which interacts with pallet_balances via Currency trait. For some reason, when I call any operation on currency trait (like Slash on screen below), it is not aligned to ...
4
votes
3
answers
48
views
How to independently check in which block extrinsic got included?
The standard way to track extrinsics is:
api.tx.balances
.transfer(recipient, 123)
.signAndSend(sender, ({ status, events }) => {
if (status.isInBlock) {
// here we know that our tx ...
3
votes
0
answers
32
views
How to compare current date with a stored date in a Substrate blockchain module?
I'm working with a Substrate blockchain and have a structure with a field named end_date. I'd like to check if the current date is greater than end_date within a Substrate runtime module, but I'm ...
3
votes
0
answers
34
views
How to get runtime types in polkadotjs (typescript)
In subxt we can have Rust types directly from scale-encoded runtime metadata. Is the same possible in polkadotjs? Is there a "polkadots" which has typescript types automatically derived from ...
4
votes
1
answer
108
views
How to convert Account ID into Account Bytes in Hex using polkadot js?
I'm following this article about substrate keys. And I was unable to convert the account ID to account bytes in hex as it guides:
from this:
Account ID
...
2
votes
1
answer
95
views
How to Implement MaxEncodedLen Trait for Structs Containing Vec<u8> in Rust
i'm trying to create a blockchain runtime module using Substrate. I have defined a few data structures with the #[derive(MaxEncodedLen)] attribute, but I'm running into a problem when trying to ...
5
votes
1
answer
132
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?
6
votes
0
answers
66
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 ...
4
votes
1
answer
88
views
Creating SignerPayload for PolkadotJS Extenstion: Unsupported extrinsic payload version 0
I am trying to create a SignerPayloadJSON from an encoded partial extrinsic in polkadotjs. The partial extrinsic has the following hex representation
...
3
votes
1
answer
70
views
Problem deploying smart contract on rococo
I have been following the public documentation of polkadot API to deploy contract: https://polkadot.js.org/docs/api-contract/start/code
but I'm getting error Uncaught (in promise) TypeError: code.tx....
4
votes
2
answers
50
views
How does the PolkadotApps get the lease period?
On the parachain auction page. IIUC, there isn't any on-chain storage to store these values. How can I get that?
5
votes
1
answer
39
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 ...
4
votes
1
answer
35
views
Listen to balance changes wrong after transfer token
I'm facing an issue. I used a query subscription to listen and update the free balance on UI. But I don't know why, when I log free in callback, they always return a balance of receiver and then a ...
3
votes
1
answer
35
views
Expose a custom `pub fn` from my pallet to frontend via polkadot.js API
I have a pallet that does some light calculation on one or more storage items (GasReserve and IdleFunds below) or wraps some internal functionality. E.g.
impl<T: Config> Pallet<T> {
...
2
votes
1
answer
51
views
I Can't Generate The right AccountId from Ethereum(H160) Address
I am writing a test to test evm contract instantiation using polkadot api.
I get to derive the evm account like this:
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
const ...
2
votes
1
answer
55
views
Polkadot.Js not showing identities of stashes on parachain rpc server
We are running public relaychain rpc endpoints and are further deploying polkadot-parachain endpoints, starting with statemine/statemint/westmint.
Everything works but when using our endpoints in ...
3
votes
1
answer
166
views
Polkadot.JS API / Reconnect
At times when using Polkadot.JS/Api connections would either timeout or become disconnected from the provider. When this happens the app crashes and exits.
Is there any native setting to reconnect ...
1
vote
1
answer
16
views
Implementing Stacking and Creating a Council in a Local Testnet
how we can implement stacking and made council in local testnet ?
Thanks in Advance,
1
vote
1
answer
43
views
How to create address book?
I'm making a wallet that has an address book / contacts feature so that it's easier and faster for users to send balances to other users.
Is storing the address book / contacts in the network is a ...
1
vote
1
answer
26
views
How to send data to custom network?
is there any simple example to send data to network?
like name, email, phone, address (which is made keyring), and address, etc
4
votes
1
answer
145
views
how to get metadata as a `0x${string}` type
Hello guys i am trying to get the metadata as a 0x${string} type. I am calling the api endpoint state_getMetadata with await api.rpc.state.getMetadata() however this returns an object of Metadata and ...
0
votes
0
answers
87
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
1
answer
44
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 === ...
3
votes
1
answer
37
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
1
answer
40
views
Output null when using ContractPromise for ink! v4 smart contract
I create a smart contract using ink! v4.2 and deploy it using contracts-ui.substrate.io
Then in my front (which uses @polkadot/api-contract: 10.7.2, @polkadot/api: 10.7.2) I run this code:
await ...
3
votes
1
answer
29
views
Get extrinsic fee using Polkadot.js/api
I want to get extrinsic fee using polkadot.js/api.
I am checking kusama chain.
https://kusama.subscan.io/extrinsic/17981827-3
I need to get 0.00053835621 fee from above extrinsic. Which api can I use ...
4
votes
1
answer
83
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 ...
3
votes
1
answer
47
views
How can I sign and execute transactions using custom origin(20 bytes address) in PolkadotJS
I have a pallet which ensures a particular custom origin of H160(20 bytes). Actually, this pallet is to ensure that the Origin is that of an ethereum address(20 bytes).
I am therefore writing ...
3
votes
1
answer
144
views
How to encode an extrinsic for RPC from a web client?
I need to programmatically pack an extrinsic for an RPC, I believe I'm looking for the following front-end functionality:
extract relevant indices from the Metadata
fill the extrinsic parameters
...
3
votes
1
answer
32
views
Is there a way to render all values of a storage in drop down through Polkadot JS UI?
I have a scenario where I have to enter all values of a storage in drop down through Polkadot JS UI.
Suppose I have a pallet TestPallet and an extrinsic rate. There are two storage Items and Rating.
...
3
votes
1
answer
69
views
Can I use event data from previous calls in a batch?
Considering the following scenario, is it possible to execute all calls in a batch and therefore sign only once using utility.batchAll in polkadot.js?
Create PureProxy from account A
Assign account X ...
3
votes
1
answer
63
views
How to connect the our local chain to the frontend?
I want to build a frontend for our local chain. how can we connect our local to chain to the frontend?
4
votes
1
answer
33
views
Why doesn't getMetadata show my callable methods as extrinsics in Substrate-node-template
When running Substrate-node-template - basically the Kitties - and with a callable eg create_kitty() as a dispatchableResult in the call pallet, what I assume to be an extrinsic in the metadata, this ...
1
vote
1
answer
51
views
Frontier template using sr25519 - polkajsapi
I just cloned frontier and modified the code for using H256 address following this
These are my changes in runtime/src/lib.rs:
pub type Signature = MultiSignature;
impl pallet_evm::Config for Runtime ...
2
votes
1
answer
40
views
How to get the dispatch error as return variable?
After transaction is send, it waits till block is included.
The following code though transaction gets successful, it doesn't return the value:
export async function transfer_balance(wsprovider, ...
0
votes
0
answers
28
views
How to log events on frontend dapp from emit_event of smart contract?
I'm currently struggling on obtaining logs of the events emitted from my smart contract on the frontend dapp. The smart contract code itself should work just fine as it emits the event perfectly fine ...