Questions tagged [polkadot-js]
Questions about the Polakdot JS API used to interact with Substrate based chains via JavaScript.
132
questions
0
votes
2
answers
13
views
How can I query how many decimal places does a Substrate asset have?
For example, DOT has 10 but can I check it in Polkadot JS Apps? I want to apply it to all parachain assets.
0
votes
1
answer
29
views
Outdated contract-api documentation
Trying to follow these examples:
https://polkadot.js.org/docs/api-contract/start/code#create-a-blueprint
which fails with:
createBlueprint is not a function
Seems like the examples in the ...
0
votes
0
answers
7
views
Error making .multi subscription call (Kitties Tutorial)
The error I see in the browser console is:
VEC: Unable to decode on index 0 createType(Lookup9):: Expected at least 32 bytes (256 bits), found 16 bytes
Offending code snippet (from Kitties.js):
// ...
0
votes
0
answers
33
views
Empty address in api.query.system.account in Polkadot.js/api
I can get account information by passing address in api.query.system.account in Polkadot.js/api.
However, if I pass empty address(''), then I can get still response.
For example free balance data in ...
1
vote
1
answer
31
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 ...
0
votes
0
answers
9
views
Filter events for specific account in Polkadot.js/api
I am trying to get list events by filter for specific account(validator, nominator).
I can get list of events using api.query.system.events(). However, if I get events for a day, there
will be much ...
0
votes
1
answer
26
views
Get Transaction by Hash
I'd like to get transaction info like sender and receiver address etc. by sending transaction hash as a parameter.
I did found "api.rpc.eth.getTransactionByHash" and tried to pass the hash ...
0
votes
1
answer
26
views
Parity signer fails to sign transaction with polkadot.js
I have an account created with ParitySigner.
I am trying to add an account with a QR code to Polkadot.js and transfer money from that account with ParitySigner.
However, when I read the QR code in ...
2
votes
1
answer
57
views
Browse events in Polkadot.js/api
I want to get events list by using polkadot.js/api.
I can see api.query.system.events() in docs.
Docs: https://polkadot.js.org/docs/substrate/storage#eventcount-u32
However, this api lists events for ...
1
vote
1
answer
23
views
get bonded balance using API
This is how to get the free balance of an account:
api.query.system.account(stash_account_address).data.free.toBigInt()
How to get the bonded balance instead?
3
votes
2
answers
107
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-...
1
vote
1
answer
14
views
Recurring Proposal on Substrate Frontend
So from polkadot js (UI) while creating treasury proposal and want to make it recurring per cycle, you do you achieve that? Say set the segment input in the picture attached to any positive integer, ...
0
votes
0
answers
23
views
Running a listener node in ReadOnly mode
I would like to run a non-validator node (listener node) and prevent it from accepting and broadcasting transactions (ReadOnly mode). Except for accepting transactions, I would like it to behave like ...
0
votes
1
answer
18
views
polkadot js how to send all the funds
I am trying to send all the available funds using polkadot.js how does one do that?
I have seen in the polkadot-ui one can purge the sender account or send all available funds and am wondering how can ...
0
votes
0
answers
31
views
Ink contract deployment out of gas
When deploying a smart contract on local-net, polkadot.js fails with:
system.ExtrinsicFailed, contracts.OutOfGas
This seems to be due to having the following enum in the contract storage:
#[cfg_attr(...
0
votes
2
answers
19
views
runtime custom rpc is not taking "at" params as optional
I have an rpc
#[rpc]
pub trait ShivarthuApi<BlockHash> {
#[rpc(name = "shivarthu_challengerevidence")]
fn get_challengers_evidence(
&self,
at: Option<...
-1
votes
1
answer
23
views
how to teleport assets between statemint and polkadot in javascript
i have not found the examples to teleport between statemint and polkadot. is ther any one can give some examples in javascript.what i use is
@polkadot/api
this is my code:
i have found the teleport ...
4
votes
1
answer
48
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....
0
votes
1
answer
30
views
understand the implementation of substrate-api-sidecar
I want to know the implementation of http://127.0.0.1:8080/blocks/head endpoint from (https://github.com/paritytech/substrate-api-sidecar)
I found some interface here https://github.com/polkadot-js/...
1
vote
0
answers
26
views
How do I call the RPC method `contractInfoOf` using curl?
The docs state that the RPC comes with a few defaultRPCs and then links to polkadotJS documentation on the available API calls. This doesn't help me if I want to call a method using curl.
Does anyone ...
0
votes
1
answer
35
views
How to use API to find balances for all different tokens on a chain?
I know that you can use the Polkadot.js API to find the balance for the native token from the system constants like so
const { nonce, data: balance } = await api.query.system.account(ADDR);
Is there ...
0
votes
1
answer
32
views
How to create and sign a transaction by myself
I am developing the tool to create and sign a transaction, but I find nothing about the format of a transaction before signing. Could you please help me to find out the document about this issue. ...
1
vote
1
answer
21
views
Polkadot{js} state queryies example not working
I am trying to run one of the examples in the Polkadot{.js} documentation and it is not working for me in TypeScript. This much works
const wsProvider = new WsProvider('wss://rpc.polkadot.io');
...
2
votes
1
answer
23
views
What does 'Future' mean as an extrinsic's result status?
I am expecting result.status.isFinalized for a balances.transfer call but within the result callback I get status: 'Future' and nothing else. What does it mean?
0
votes
1
answer
37
views
Scale Codec for Dart
There are a couple of packages that are outdated or do not have the features I need for Dart-lang. So, I decided to code my own. There are really good implementations coded in various languages that ...
2
votes
1
answer
32
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 ...
0
votes
2
answers
37
views
How to prevent / remove duplicate modules and mismatched version numbers (i.e. @polkdadot/types)?
I am still learning TypeScript and I have some code that is working, but it returns a lot of messages about multiple versions of modules and conflicting packages. What is the best way to fix these ...
1
vote
0
answers
52
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 ...
0
votes
1
answer
31
views
Updating metadata with a single transaction
Is it possible to update all metadata for all chains on Polkadot.js by signing only one transaction?
0
votes
1
answer
25
views
How to query block length using polkadot-js
How can I query the length of a block used for normal transactions?
After seeing check_block_length, I would have expected to be able to use allExtrinsicsLen, but this always returns None, even if the ...
2
votes
1
answer
114
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 ...
1
vote
1
answer
14
views
How to do a democracy pallet vote using Polkadot API in typescript
I am trying to do a democracy vote using the API.
First I am getting the balance of my account:
const balance = (await api.query.system.account(my_account)).data.free;
const voteConfig: Vote = ...
1
vote
1
answer
29
views
Decode Map keys in call to Struct.toHuman()
I have the following struct, where Characters is the newtype idiom around Vec<u8>.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct OperationData {
config: BTreeMap<...
0
votes
0
answers
13
views
How to do "erasStakers" in Rust?
Very sorry for such a newbie question; just don't know where else to ask 🙏
Essentially, I want to programmatically dump from the network who won the most recent election. To do so, I'm issuing an ...
1
vote
1
answer
16
views
Why is result.status undefined in an extrinsic's SubmittableResult?
I am using the substrate contracts node and my transactions are successfully submitted to the chain. I've checked using a dry run query and also checked in the explorer for the block after performing ...
1
vote
0
answers
16
views
Read Token Contract Information
I would like to read contract information(especially name, symbol, decimal, owner) from token contracts like shown here: https://moonbeam.moonscan.io/token/0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b#...
2
votes
0
answers
46
views
Custom typegen and using ApiPromise: Property 'unwrap' does not exist on type 'Codec'
It seems there is a mismatch between autocomplete suggestion return types from an ApiPromise instance and the actual returned type.
I am using "@polkadot/api": "8.1.1". I am ...
2
votes
1
answer
35
views
Which event should I listen to in order to get contract instantiation data?
I'm trying to index the names and decimals of tokens in moonbeam, I think I should listen for a contract instantiation event to get that data. Which event and module should I listen for? Or is there ...
1
vote
0
answers
12
views
Why after passing more than 24 hours some tips close button on Polkadot js are still grey/disabled?
After a treasury tip receives "half + 1" tips from the councils, It goes to the countdown period. I run api.consts.tips.tipCountdown on Polkadot an get 14,400, which should be in blocks! If ...
1
vote
1
answer
70
views
Issues with Ledger Nano S Plus - not able to sign for Polkadot.js web extension
Anyone know how to get in touch with the devs behind the Polkadot Ledger app? I am having issues with the Ledger Nano S Plus when using Polkadot.js web extension? When I try to sign, I get this ...
3
votes
1
answer
36
views
Mocking Polkadot requests in Jest
I'm building out some local unit tests and am trying to figure out how to mock Polkadot requests/responses. I'm trying to get mock-socket working, wondering if there is any documentation on using this ...
1
vote
1
answer
17
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?
0
votes
0
answers
21
views
Performing auction on Rococo local - error after completed auction
I have been tried to perform crowdloan and auction on local Rococo, using this relay chain chainspec.
Steps:
Reserve paraid
Register parathread
Add crowdloan campaign for reserved paraid
sudo -> ...
2
votes
1
answer
36
views
Error generating types/type interfaces
I'm trying to generate type interfaces using definitions directly from Substrate and ORML libraries. I'm using the polkadotjs package versions 8.1.1.
My type generate file looks like:
import * as ...
2
votes
1
answer
26
views
Get all runtime storage `Orders` values from the client
1 the runtime storage order type as follow:
// Order storage
#[pallet::storage]
#[pallet::getter(fn order)]
pub type Orders<T: Config<I>, I: 'static = ()> = StorageMap<
...
1
vote
1
answer
31
views
The era of Sign with no submission action is different than submit
I'm using a ed-25519 account, and first sign with no submission, and use the 「Signed transaction」to decode, the result(right pic) show the era Period is 0x40...
then I do a real submit, but the ...
3
votes
2
answers
95
views
What are the set cli commands to stake on a validator node?
In this video Joe Petrowski demonstrates a command which allows us to set a stake and also choose a reward destination. But unfortunately some of the command gets obscured by their video picture.
As I'...
1
vote
1
answer
21
views
Why signature diverse with same additon signed of SignedExtension?
I have a same call with same era,nonce,tip, and a same signer. the SignedPayload is construct by call and Extra(era,nonce,tip here), so the payload should be unchanged. but in polkadot.js I checked ...
1
vote
1
answer
40
views
Transaction hash when call extrinsic
Is there any way I can get the state of the extrinsic when I initiate the call before the block is finalized?
Thanks
4
votes
1
answer
20
views
Generate documentation with base types from a substrate node
I'm trying to generate documentation for substrate RPC queries using the meta property in the @polkadot/api library. Something like api.query.<pallet>.<storageitem/extrinsic>.meta. This ...