Questions tagged [typescript]

TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript. It adds optional types, classes, interfaces, and modules to JavaScript. This tag is for questions specific to TypeScript. It is not used for general JavaScript questions.

Filter by
Sorted by
Tagged with
1 vote
1 answer
58 views

Getting NFT metadata in polkadotjs with typescript

I'm trying to call api.query.nfts.itemMetaDataOf<type>(collection_id, token_id); via typescript and polkadotjs. It's not clear which type I'm supposed to use for the response. At least I can't ...
Arjan van Eersel's user avatar
0 votes
0 answers
20 views

subsquid: extrinsic fee not populated in block.extrinsics

What config is needed in order to see the fee for each extrinsic? While following the Transfers example, I try to see the extrinsic.fee in processor.ts export const processor = new ...
DerekC's user avatar
  • 1
0 votes
0 answers
26 views

generate types from chain does not work. Documentation is not clear

I dont think typegen is working as expected per documentation, by following the provided example and adapting it to my parachain. ` Found 244 errors in 5 files. Errors Files 5 src/interfaces/augment-...
rvalle's user avatar
  • 45
2 votes
1 answer
56 views

Is `createType` safe to use in polkadot-js/api

In this comment of pjs github, it says that we should never do the following: const something = api.createType('SomeType', { foo: 'bar' }); ... await api.tx.somewhere.something(something); ... and ...
Tarik Gul's user avatar
  • 1,106
1 vote
0 answers
29 views

Substrate enum to typescript(polkadot-js)

I am new to Substrate and Polkadot-JS. I am attempting to convert this enum with values to TypeScript, but I haven't been successful so far. I really appreciate any help you can provide. pub enum ...
Uncle_Sam's user avatar
0 votes
1 answer
33 views

Polkadot Typegen importing JS extension instead of TS

We are using the typegen to create types for our custom chain. Following the docs The code that is generated is kinda strange. In the augment-api.ts file it tries to import all the other generated ts ...
donkeydonkey's user avatar
1 vote
1 answer
129 views

Decode event data

I am learning to use polkadotjs api, I am trying to send a system.remarkWithEvent and then get the event that this created and decode de output to verify that the remark is there. The sending of the ...
Valentin Fernandez's user avatar
3 votes
1 answer
49 views

subscriptions with parameters in polkadot.js api

I am using React+Typescript and trying to retrieve data from a struc using a query subscription. I first tried the following in order to check that I'm retrieving the right data: api.query.rolesModule....
Kazunobu Ndong's user avatar
2 votes
1 answer
80 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 ...
Michal Danco's user avatar
3 votes
0 answers
44 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 ...
Hugo Trentesaux's user avatar
3 votes
1 answer
98 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` ...
drhanlondon's user avatar
0 votes
1 answer
24 views

what is the correct typescript syntax for declaring the return type of session.queuedKeys()

in this pull request, i attempt to add support for looking up the collator account associated with a given nimbus session key. the method implementation in the pr is as follows: export function ...
grenade's user avatar
  • 476
1 vote
1 answer
173 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 ...
Ross's user avatar
  • 161
2 votes
1 answer
55 views

Errors on generated code from Typegen

We are following the polkadot{.js} docs on TypeScript user generated for Chain modules. We are trying to get our custom chain module types into Typescript. We can generate fine however the generated ...
donkeydonkey's user avatar
2 votes
1 answer
124 views

MultiLocation type polkadot js

I am trying to figure out correct way how to type MultiLocation type I thought that I would do import {MultiLocation} from "@polkadot/types/interfaces" const location: MultiLocation = { ...
Michal Danco's user avatar
2 votes
1 answer
100 views

How do I include a tip for transactions using Polkadot.JS/API

I am attempting to add a tip to a transaction in the following manner: const batch = await api.tx.utility.batch([...]); batch.tip = 1; It appears that tip is a read-only property and I'm receiving an ...
Paradox - ParaNodes.io's user avatar
1 vote
1 answer
118 views

Custom ChargeTransactionPayment type for extrinsics

if the type for extrinsic verification pub struct ChargeTransactionPayment<T: Config> has been changed on a chain, how do we update the polkadot.js API to use the new types? Suppose the type has ...
Emmanuel Thomas's user avatar
1 vote
0 answers
17 views

UnsubscribePromise not being returned from subscription

When I try to create a subscription from a custom pallet, it doesn't return a UnsubscribePromise (like the native ones), but returns a Promise<Codec>, even though I added a callback as the last ...
Pedro Filho's user avatar
0 votes
1 answer
190 views

How do we work with polkadot-js enums in TypeScript?

I used typegen to generate my types from definitions. Definition Person: { status: 'Status', balance: 'u128', }, Status: { _enum: ['Active',...
forgetso's user avatar
  • 1,492
0 votes
1 answer
235 views

Extracting error from system.ExtrinsicFailed

I have a call to an extrinsic (in a Typescript/RxJS client) that is failing but I want to be able to catch the error that the extrinsic is throwing and not just that it failed. const chainEvents: ...
Robert La Ferla's user avatar
0 votes
1 answer
344 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(...
rajohs's user avatar
  • 491
1 vote
2 answers
384 views

Typescript errors when using @polkadot/api

I'm building a typescript project and I'm trying to do the very simplest thing as a first step with Polkadot: Connect to a node and get account information. However, when I run tsc, it totally blows ...
kael's user avatar
  • 109
3 votes
2 answers
143 views

How to decorate polkadot.js api with upcoming runtime features

There's upcoming features coming to pallet uniques. They are now merged to master of substrate repo but not yet released. We would like to be prepared for it on Singular marketplace but not 100% sure ...
Yuri's user avatar
  • 173
1 vote
2 answers
57 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 ...
forgetso's user avatar
  • 1,492
1 vote
1 answer
95 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'); ...
Roger J Bos CFA's user avatar
3 votes
2 answers
2k 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 ...
Roger J Bos CFA's user avatar
1 vote
1 answer
63 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 = ...
nicolasochem's user avatar
2 votes
1 answer
245 views

How do you resolve missing type errors in the @polkadot/api v7.x.x packages?

Upgrading from: // package.json "@polkadot/api": "^6.7.2", "@polkadot/types": "^6.7.2", to: // package.json "@polkadot/api": "^7.7.1", &...
tarrball's user avatar
  • 225