Questions tagged [polkadot-js]
Questions about the Polakdot JS API used to interact with Substrate based chains via JavaScript.
464
questions
1
vote
0
answers
7
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 ...
4
votes
1
answer
31
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 ...
1
vote
1
answer
10
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
3
votes
1
answer
83
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 ...
3
votes
1
answer
28
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 on the screen depending on the logged user/account being the owner or not so to have something similar to:
accountPair.address ===...
5
votes
0
answers
27
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": &...
1
vote
1
answer
24
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
76
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 ...
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
1
answer
37
views
How do withdraw or transfer tokens from the custom predefined accounts in a private network?
I've created a custom network from node-template with more pallets (staking, babe,...)
I've generated a custom chain_specs.json following this tutorial
chain_specs.json
{
...
"genesis"...
1
vote
3
answers
117
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
...
2
votes
1
answer
20
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 ...
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 ...
1
vote
1
answer
25
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 ...
2
votes
2
answers
75
views
I'm getting some issue during storage migration
I'm trying to trigger the storage migration on polkadot UI for our parachain. I'm trying different types to do this but getting some issues:
Type 1 : If I simply upload the wasm file from sudo > ...
2
votes
1
answer
78
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
...
1
vote
1
answer
23
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
49
views
What's the difference between `paymentInfo` and `gasRequired`?
In polkadotJS there are two ways of getting gas estimates (specifically WeightV2) before you send a contract transaction.
The first uses query and returns a gasRequired value in the result.
const ...
3
votes
1
answer
57
views
Encode strings to SCALE encoded smart contract calls
I'm looking for a way to encode smart contract calls in javascript code with polkadot-js, the same way I can do it from the web UI, but I cannot find a description of the available API in the ...
2
votes
1
answer
54
views
ContractPromise from Polkadot Js do not load contract ABI when intantiating
I am using ReactJs and ContractPromise object cant/dont access contract query and txs object.
const contract = new ContractPromise(api,metadata( in json even string format), address);
The object ...
2
votes
1
answer
60
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 ...
1
vote
1
answer
20
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
41
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?
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 ...
2
votes
1
answer
34
views
Implementing contract token transfers between users in a Substrate-based DEX
I am working on a decentralized exchange (DEX) using the Substrate framework, and I need help with transferring non-native tokens between user accounts within the DEX.
Suppose a user creates a token ...
0
votes
1
answer
22
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
78
views
What informations consist of a signature which is generated when siging a transaction payload offline?
From the wiki (https://wiki.polkadot.network/docs/build-transaction-construction),
import { createSignedTx } from "@substrate/txwrapper-polkadot";
// Example code, replace `signWithAlice` ...
1
vote
1
answer
17
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, ...
1
vote
1
answer
521
views
API-WS: disconnected from ws://127.0.0.1:9946: 1006:: Abnormal Closure
I'm trying to connect local node running on my pc using polkadot.js library in react.js(browser). I'm pasting my code in below snippet and error that I'm facing in chrome console
Code
// **************...
0
votes
0
answers
16
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 ...
2
votes
1
answer
190
views
Not able to run PolkadotJS apps on local
I tried to clone https://github.com/polkadot-js/apps and run on local. When I execute yarn or yarn install, I get below logs:
➤ YN0013: │ @polkadot/react-identicon@npm:3.4.1 can't be found in the ...
2
votes
1
answer
85
views
@polkadot/api suppress output messages
I have an issue regarding displaying errors. For errors, the logger @polkadot/api uses will write to console even when the error is caught and handled. I am handling and displaying the messages a ...
2
votes
1
answer
2k
views
Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
Prior to cloning the substrate-front-end-template repo with tag "monthly-2022-02" I installed the following since I was building it from a Dockerfile using pre-built Docker image node:...
2
votes
2
answers
123
views
polkadot js RPC can't get u128
i have an rpc call that returns an array of structs with multiple fields, one of which is balance of an asset for a user, balance type is u128. when the number is large i get this error createType(...
2
votes
1
answer
29
views
problem with sign wallet for use in substrate and nodejs : Cannot read properties of undefined (reading 'specVersion')
i wanna to craete wallet for user in nodejs and substrate . i using these codes for connect to substrate node and create a wallet :
const { ApiPromise, WsProvider } = require('@polkadot/api');
const { ...
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, ...
2
votes
1
answer
24
views
How to fix "module group is private" error when using frame-support-procedural-tools v3.0.0?
I'm trying to use orml-tokens in my Substrate project and encountered the following error:
error[E0603]: module `group` is private
--> /home/kianoush/.cargo/registry/src/github.com-...
2
votes
1
answer
37
views
trying to yarn build polkadot-js/apps and getting error
I'm trying to clone and build this branch (supersig-v1.0.0-ninja-2), but getting an issue on my mac, while on ubuntu it works fine.
yarn build:
error:
apps % yarn build:code
$ polkadot-dev-build-ts
$ ...
3
votes
1
answer
42
views
Cannot connect to PJS Apps or Substrate front-end template with a custom endpoint
I have set up a Network of two Nodes in a local Network, but I cannot get the Polkadot Block explorer (polkadot.js.org) or the substrate-Front-End-Template to connect to it.
the polkadot app ...
2
votes
1
answer
45
views
How to troubleshoot synchronisation issues between two nodes in a local Substrate blockchain network using server?
I am trying to set up a local blockchain network using the Substrate framework and two separate servers running on Alice (port 9944) and Bob (port 9944). However, I am encountering an issue where the ...
1
vote
1
answer
189
views
Suppress Warning "API/INIT: RPC methods not decorated"
Is there a way to suppress this warning when using Polkadot.js?
API/INIT: RPC methods not decorated: chainHead_unstable_body, chainHead_unstable_call, chainHead_unstable_follow, ...
4
votes
2
answers
50
views
Is there any storage for the blocks in blockchain?
I was working on migrating data from one blockchain to other blockchain. I have migrated much of my data. Now i was trying to migrate the blocks of the blockchain.I want to know that where is the ...
2
votes
1
answer
80
views
How to access wallet only with a private key
I don't have a seed phrase.
I have private key, ss58, public key, accountID key.
Need a seed phrase to access polkadot.js wallet.
When I put the private key in the seed key input box, the ss58 address ...
3
votes
1
answer
30
views
what is the `deprecation of the balances.transfer` meaning at Polkadot v0.9.42?
The link: https://github.com/paritytech/polkadot/releases
The message: Please note the upcoming deprecation of the balances.transfer call.
What is the Balances::transfer becomes Balances::...
2
votes
1
answer
30
views
Polkadot-JS not calling my contract properly
I used PolkadotJS to call a contract, when i did, it logged the status "in block", Turns out it never makes any state change. I used contracts-ui it worked, but with JS? Never. What can be ...
1
vote
0
answers
35
views
How can I decode this error message {"ok":{"flags":["Revert"],"data":"0x000110"}}?
I'm using polkadotjs to call my ink! smart contracts and I seem to be having trouble with calls that require parameters. For the call below I am getting the revert flag {"ok":{"flags&...
5
votes
1
answer
116
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....
1
vote
1
answer
37
views
Receive XCAV token to sporran wallet
We've minted some ERC20 tokens XCAV coins on our node. Can the Sporran wallet receive XCAV token? I transfer XCAV and it success but I didn't saw any token in wallet.
Someone please give some advice. ...
3
votes
0
answers
76
views
In-browser signing of payload generated with subxt
I am generating a partial unsigned extrinsic via subxt however cannot figure how to how to sign it using the polkadot.js api. For example:
#[subxt::subxt(runtime_metadata_path = "...
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 ...