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
6
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
9
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 ...
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": &...
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 ===...
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 ...
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 ...
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 ...
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 ...
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
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.
...
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
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?
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 ...
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 ...
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, ...
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
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
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::...
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
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&...
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 ...
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
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 = "...
2
votes
1
answer
21
views
Cannot prompt wallet to connect
I have been having series of errors and I have not been able to find a solution online. Please can anyone help me? I want to prompt users to connect wallet i.e when the connect button is clicked ...
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 ...
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
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
$ ...
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 ...
2
votes
0
answers
25
views
How to create a preimage which is the batch of other preimages?
I am wondering whether, and if so how, it is possible to submit a preimage which batches over other preimages, e.g.
const pre1= '0x09401eb25e90bf587fbde8d2a9be8af5ac0f3187f02f4e9e9f1f178b0314ebe5';
...
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` ...
2
votes
1
answer
52
views
How to make orml-traits and orml-tokens compatible with sp-io version 7.0.0 in a Substrate project?
I am working on a Substrate project and want to use the orml-traits and orml-tokens crates in my custom pallet. I have added these crates to my Cargo.toml:
orml-tokens = { git = "https://github....
0
votes
1
answer
16
views
Add Nicks pallete [closed]
lenovo@lenovo-IdeaPad-3-15ADA05-Ua:~/substrate-node-template$ cargo check -p node-template-runtime
error: failed to load manifest for workspace member `/home/lenovo/substrate-node-template/node`
...
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 ...
1
vote
0
answers
30
views
How to calculate claimable rewards from dApp Staking on Astar and Shibuya across multiple eras and multiple dApps?
Hi~ I have some questions about the developer staking process.
I am using polkadot-api, developer staking part on shibuya-network.
At portal.astar.network, I can see staking info on the dApp Staking ...
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-...
1
vote
3
answers
62
views
How can I handle error from batchAll extrinsic
Example:
// construct a list of transactions we want to batch
const txs = [
api.tx.balances.transfer(addrBob, 12345), (1)
api.tx.balances.transfer(addrEve, 12345), (2)
api.tx.staking.unbond(...
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 ...
0
votes
0
answers
35
views
TS type generation - @polkadot/api
I've been trying to follow the documentation for generating types for @polkadot/api https://polkadot.js.org/docs/api/examples/promise/typegen/. However the generated files seem to be missing many ...
2
votes
2
answers
42
views
Accidentally used ETH address to receive token from polkadot
I accidentally used ETH address to receive token from polkadot.
For example:
https://polkaholic.io/account/49zaADFp2kjgEJhmUWp1aq4zVc6fGBnSNFEUa4b2WAvxF73X?group=overview&chainfilters=all
Eth ...
2
votes
3
answers
69
views
How to sign an extrinsic as a smart contract in the browser?
When working with smart contracts in Contracts UI you sometimes need to call a message as the contract itself.
For example the addOwner message of the Multisig ink! example.
How can I add the contract ...
2
votes
1
answer
25
views
create service-endpoint in Kilt DID
I would like to add a service-endpoint to my Kilt DID, using the Javascript SDK.
I have created a full DID and am trying to add the service-endpoint like so:
const extrinsic = api.createType('...
2
votes
2
answers
83
views
Add blockHash parameter to Polkadot.js chainState query
For a Polkadot parachain (Zeitgeist) query, I need to add the block hash to get historical data. See this example:
When I try to try to run the same query in polkadot.js, I get an error when I try ...