Questions tagged [javascript]
Questions about JavaScript in the context of Substrate and Polkadot.
38
questions
1
vote
1
answer
42
views
How to pass value as a argument in send transactions?
An error occurred: 'Expected 2 arguments for the contract message 'vote', but only 1 was provided.First argument was of number type, and the second one an Enum . This error arises when attempting to ...
1
vote
2
answers
77
views
Reading contract value returns null
Facing an issue while trying to query for a value in my contract. The value keeps getting retuned as null with an error. However, it works fine on substrate Contracts UI
Front end Dapp :
const ...
3
votes
1
answer
18
views
Property X does not exist on type DecoratedRpc
We are currently experiencing an issue related to RPC methods. Let me provide a description of the problem:
To generate metadata from our node, we use the following command:
echo '{"id":1,&...
0
votes
0
answers
16
views
How to Implement P2P Encryption with sr25519 key pair using NaCl or alternatives?
I am currently working on a project that involves P2P encryption using Substrate addresses and sr25519 cryptographic keys. However, I am encountering difficulties in implementing encryption and ...
3
votes
1
answer
69
views
How to automatically pass the value to custom SignedExtension
For now I have custom SignedExtension in my substrate node:
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct CheckAccount<T> {
...
0
votes
1
answer
26
views
How to query api.query.authorityDiscovery.keys?
I'm trying to call api.query.authorityDiscovery.keys as is described here from rpc.polkadot.io like:
let current_auth_keys = await api.query.authorityDiscovery.keys();
and I keep getting:
TypeError: ...
0
votes
0
answers
18
views
Where in PJS Apps are signatures added to transactions & submitted?
I have been following the path of a Ledger submitted transaction on Polkadot JS Apps, and have found that the Ledger device is generating a signature here in hw-ledger/src/bundle.ts.
I am unable ...
1
vote
1
answer
77
views
Invalid Transaction: Transaction has a bad signature - Ledger signature into tx
I am attempting to submit a transaction using Polkadot JS API and a signature that has been signed by Ledger. Upon passing it to send I get the Invalid Transaction: Transaction has a bad signature ...
1
vote
1
answer
73
views
How to get raw payload from Polkadot JS transaction
As the title asks, how do we abstract the raw payload of a transaction created with Polkadot JS?
// set up a tx, e.g. join a nomination pool
const tx = api.tx.nominationPools.join(bond, poolId);
// ...
1
vote
1
answer
66
views
Trying to get an AccountId32 from a string in js
i'm trying to get an accountId32 from a string. In fact , i received account address in a telegram message but i would like to use native method has of BTreeMap<AccountId32, u32>.
anyone got an ...
1
vote
2
answers
58
views
How to verify that signed transaction, is correctly signed?
I want to decode and check if the given hex data for the transaction is valid and signed correctly.
The flowing is how I currently construct the transaction and convert it to hexadecimal format.
...
1
vote
1
answer
51
views
How to use smoldot in rust application?
I can find only javascript interfaces and documentation to interact with it, but nothing regarding rust?
Feels a bit weird to use js library for rust application in rust application. Neither subxt ...
1
vote
1
answer
42
views
Substrate-Connect Error on new ScProvider
I am using Substrate Connect in the browser following the docs for a custom chain spec. When I try to create a new ScProvider like the documentation suggests i get an error that I am missing a ...
2
votes
1
answer
40
views
Is there a .into_sub_account_truncating equivalent for Javascript?
In rust I use:
.into_sub_account_truncating()
Is there a Javascript equivalent?
1
vote
1
answer
90
views
Question for api.call.transactionPaymentApi.queryInfo state call
I'm replacing api.rpc.payment.queryInfo with api.call.transactionPaymentApi.queryInfo in the crawler code of Polkastats block explorer but I want to ask about the second parameter len: is that the ...
2
votes
1
answer
105
views
How to retrive data stored in a block
I have stored an information on chain and I want to access that information using RPC call.
I used the following code and provided the hash created.
const signedBlock = await api.rpc.chain.getBlock(...
2
votes
1
answer
61
views
Embedding javascript (wasm) in substrate runtime
I have some javascript code that I need to embed in my substrate runtime. It's not possible / practical to rewrite the javascript code in rust. I was wondering if instead it would be possible to ...
2
votes
1
answer
119
views
How to handle XCM encoding and building in JavaScript
Talisman and I are looking into building a simple JS module that helps developers build XCM for transactions and abstract common patterns like cross chain transfers into a simple JS function taking ...
0
votes
1
answer
97
views
JavaScript/TypeScript: How to pass arguments of an array individually to a function?
I want to dynamically call contract functions. The only problem with this is,
that all of the functions have a different amount of variables.
As of now, the function looks like this:
async call(...
0
votes
1
answer
29
views
Run JavaScript Js scripts in Zombienet tests and assert on the completeness or return value
I saw this in Zombienet's Testing DSL page:
https://github.com/paritytech/zombienet/blob/main/docs/src/test-dsl-definition-spec.md
Under Available Assertions
Custom js scripts: Allow to run a defined ...
1
vote
1
answer
67
views
How to change input from string to Id::Bytes in JavaScript?
I am using the openbrush standard to implement a psp34 token.
Now I want to call certain methods from said token, like for
example owner_of.
owner_of from psp34 has id:Id as an input which can then be ...
0
votes
1
answer
385
views
How can you query a smart contract using the polkadot.js api?
I want to query a smart contract which I deployed on the Aleph Zero testnet.
The Polkadot.js documentation is pretty clear and easy to follow regarding connecting to the chain and querying general ...
0
votes
1
answer
117
views
Create hex encoded call (for XCM transact call) in javascript?
I'm trying to create the encoded element for an XCM V0 transact call such as:
const message = {
V0: {
Transact: {
originType: "Native",
...
2
votes
1
answer
66
views
How to use the polkadot/dev project template
I'm trying to convert my project over to a structure similar to the @polkadotjs repositories, but I'm finding the dev template provided a bit difficult to parse. Specifically:
How do I use this ...
0
votes
1
answer
40
views
How can I listen to new receive transfer?
I want to listen to new transfers and get the hash and amount.
How can I?
Also, Can I get list transfers of account like this url?
https://westend.subscan.io/account/...
2
votes
1
answer
71
views
How to create a tuple type using polkadot.js api
I am trying to create a tuple. I know we can create an enum by defining the type as
MyEnum: {
_enum: {
'account': String,
'accountId': 'u128'
...
1
vote
2
answers
52
views
How to signAndSend() without a MNEMONIC
I'm trying to allow users on the client side send an api.tx.system.remark( 'message' ); with PolkadotJS.
I run into issues on signing and sending the transaction, as I will not have their secret key. ...
0
votes
1
answer
32
views
Get remaining value of bounty after child bounty
I am writing a web app that shows current info about bounties and child bounties. From what i understand if there is a bounty with a value of 5 DOT, I can create N child bounties which values sum up ...
1
vote
2
answers
54
views
Are there any tools available for creating a mock version of a contract in JS/TS?
Currently, we use "live" versions of our contracts running on a substrate contracts node in our JavaScript tests. This makes them integration tests and difficult to include in simple GitHub ...
3
votes
1
answer
196
views
Dev Substrate Node at Capacity for WS Connections, how to flush?
I'm running a node in dev mode: ./substrate/target/release/substrate --dev --tmp --ws-external
My client connection code:
provider = new WsProvider(wsProvider)
api = await new ApiPromise({ provider })....
3
votes
2
answers
132
views
Access your NFTs using PolkadotJS API
Still very new to this ecosystem. I'm trying to build a ReactApp that can access my NFT's that I have purchased on the Singular App.
High level explanation, how do I do this?
Low level, point me in ...
7
votes
1
answer
96
views
How to programmatically get current unbonding information on the Polkadot relay chain?
Using either a Rust or JavaScript client library I would like to get the amount of DOT that is currently being unbonded on the relay chain.
Some staking information is available in the Polkadot JS ...
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 ...
2
votes
1
answer
49
views
How to use the .multi() method? (substrate-front-end-template)
I finished the substrate kitty tutorial (backend and frontend). Now I would like to build a simple frontend for the RMRK pallet. Now I stuck on the .multi(...) method. Where can I find a documentation ...
1
vote
1
answer
61
views
Invalid params: unknown field `storageDepositLimit` Error when getting contract data from a chain
I deploy the flipper contract to Jupiter testnet, when I try to get the contract data, I got this error message although it works just fine on a local node. (I also tested on other test networks and ...
1
vote
2
answers
408
views
Transaction would exhaust the block limits error when calling a smart contract from Polkadot JS API
I'm trying to call a smart contract using the Polkadot JS API (like here). The contract function is really simple, it takes 2 strings: a key and a value as input parameters, then adds the key, value ...
0
votes
2
answers
89
views
Error encountered could not complete yarn install of substrate front end template
Followed the installation steps provided here
https://docs.substrate.io/tutorials/v3/create-your-first-substrate-chain/
Steps taken with node version v16.14.0
git clone https://github.com/substrate-...
1
vote
1
answer
126
views
OutOfGas Error when trying to read contract data using Polkadot JS API
I'm trying to read the flipper contract data from a contract in a local node, following the code in here.
This is my code:
// Required imports
const { ApiPromise, WsProvider } = require("@...