Skip to main content
6 votes
Accepted

How to make rawTransaction? and Can I get some guide or reference about offchain sign?

In order to make an unsigned transaction you can create an object with the required chain metadata and payload information: // create unsigned transaction payload const unsigned = { ...
Cameron Marshall's user avatar
5 votes

How to use Polkadot.js API for governance proxy call correctly?

To wrap something in a proxy, just pass the api.tx.<module>.<method>(...) as-is. In code it would be - function proxyVoting(address, type, ref_index, vote) { return api.tx.proxy.proxy( ...
Jaco's user avatar
  • 5,865
5 votes
Accepted

Can I call external APIs inside my pallet?

To add to Sam's post: It should be noted that Offchain Workers are very often misunderstood. It is not trivial just to write some random http request as part of pallet development and expect it to ...
Shawn Tabrizi's user avatar
  • 16k
5 votes

Can I call external APIs inside my pallet?

The Off-chain worker was introduced directly to solve this problem. You can see a full guide on how to do GET/POST requests here Some sample code // We want to keep the offchain worker execution time ...
Sam Elamin's user avatar
  • 1,223
5 votes
Accepted

Using polkadot.js api, how can we list the members of a Kusama nomination pool?

It is a map. So to get .entries() you specify no parameters as per the docs. Params would only come into play with higher-order maps as per docs. To get all the entries of the pools - const e = await ...
Ben Travers's user avatar
5 votes
Accepted

How to change input from string to Id::Bytes in JavaScript?

For any enum, the input is index + bytes. So depending on the enum, the first byte needs to be the actual enum id or (in the case of the JS API) identify the enum, type. Since you have no info, some ...
Jaco's user avatar
  • 5,865
4 votes
Accepted

OutOfGas Error when trying to read contract data using Polkadot JS API

The error is telling you that the gas limit you have provided is too low. You supplied a limit of 3 * 10^9 which is 3 milliseconds of execution (1 gas = 1 pico second). This could be too less if the ...
Alexander Theißen's user avatar
4 votes
Accepted

How do I obtain key-value storage proof for a runtime call?

It is possible to collect a witness for having an runtime API handle at hand. The key methods are record_proof and extract_proof. Assuming you have a Client instance at hand, you can do the following: ...
pepyakin's user avatar
  • 2,174
4 votes

Access your NFTs using PolkadotJS API

If you want to gain Access to NFTs which you purchased on Singular, then you are dealing with RMRK NFTs which live in Smart Contracts deployed to the Moonriver Network which is a L1 parachchain on ...
Achim's user avatar
  • 575
4 votes
Accepted

How to get output when calling a contract method and signing it?

Like P.Ossun said, the solution is to dry-run the contract first and check the answer, then to run the contract again, this time making actual changes on the blockchain. Here you can find the ...
rajohs's user avatar
  • 491
4 votes

How to save decoded events using polkadot.js?

All you want to do is have the data available outside the callback. So just set it to some variable - let decoded = null function setDecoded (value) { decoded = value } contract.tx .method({ ...
Barto's user avatar
  • 584
4 votes
Accepted

Error: Unable to initialise options more than once

We can see here the KeyringOptions which contain the KeyringStore. Those options are what's called by loadAll() in line 326: this.KeyringOptions.init(this). If we then go to see what that init does, ...
Alberto Nicolas Penayo's user avatar
3 votes

Polkadot.js API how to add the name of an item and collection of NFT's using uniques

name comes from ipfs JSON object that you can add using setMetadata call. Let's say you have an object like { name: 'My NFT #1', description: 'My first NFT on pallet uniques', } You then pin this ...
Yuri's user avatar
  • 173
3 votes
Accepted

how to verify that my validator has the right session keys

Replying to myself. It actually works the way I described it, not sure why I thought otherwise initially. let nextKeys = await api.query.session.nextKeys(stash_account); let nodeHasKeys = await ...
nicolasochem's user avatar
3 votes
Accepted

How to get StorageKey associated with an address?

You can also use the apps UI to create keys, generally if these are single items this is a quick approach. In the apps UI via the storage page, you can see the encoded keys based on the input ...
Jaco's user avatar
  • 5,865
3 votes

Query account balance with HTTP calls

Here is a simple example of getting Polkadot's total issuance: curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "...
Bruno's user avatar
  • 8,365
3 votes

Help needed with payloads and extrinsics

If I look at the above, if it is meant to be a full payload there is certainly seems to be information missing, most notable the actual call. So first the basics - some of the signed extension ...
Jaco's user avatar
  • 5,865
3 votes

How to access storage items using polkadot js, javascript playground

Probably the error here is due to Rust doing things with snake_case/UpperCase, and JavaScript doing things with camelCase. I would never expect that the Polkadot JS API would expose a function which ...
Shawn Tabrizi's user avatar
  • 16k
3 votes
Accepted

How to call prefixed by trait(interface) methods using the polkadot api?

PSP34 in the rust level is a trait(interface) implemented by your contract. At the ABI level is a prefix or a namespace of the method that makes it unique. It allows supporting several methods with ...
Green Baneling's user avatar
3 votes

How to save decoded events using polkadot.js?

This is a good question. From all the examples that I have seen, it looks like you may have to have your program logic inside the signAndSend. Also, a note that contract.tx.method({ ...
Bruno's user avatar
  • 8,365
3 votes

How to query transaction details by using the transaction hash on polkadot by using python

Transaction hashes have a different meaning in Polkadot than in Ethereum. Ethereum TX hashes uniquely identify a transaction in a Block. TX hashes in Polkadot are not necessarily unique. They are ...
Oliver Tale-Yazdi's user avatar
3 votes
Accepted

How to call payable methods with the polkadot API?

You need to add { value: valueToBeSent } as the last argument in the method .method( arg1, arg2, { value: valueToBeSent }) This is how it works for tx call: await contract.connect(owner).tx....
Maario's user avatar
  • 659
3 votes

What is the smartest way to make multiple dynamic storage queries using subxt?

The options that I'm aware of are: to do what you've done (whether you use static or dynamic storage lookups). Use the "lower level" RPC method (api.rpc().query_storage_at(..) to query ...
jsdw's user avatar
  • 1,335
2 votes
Accepted

Substrate Sidecar Custom Type Issue

Geez... remove the outer types property so just have: { "AccountInfo": "AccountInfoWithRefCount" } And everything works... maybe this will help someone else.
Will White's user avatar
2 votes

How do I write custom a custom api-derive?

Take a look at this @polkadot/api issue. Basically the poster had the same question. In this case it led to an enhancement making the derives augmentable (usage below copied from this PR) and that ...
Jaco's user avatar
  • 5,865
2 votes

DRR: createType(ExtrinsicStatus):: Cannot map Enum JSON, unable to find 'reason' in future, ready, broadcast, inblock, retracted, finalitytimeout

This was caused by the testing (pre-release) versions of the RPC nodes running the new jsonrpsee server. The best way to test RPC nodes is under load... It has been addressed since this was raised, i....
Jaco's user avatar
  • 5,865
2 votes

Access your NFTs using PolkadotJS API

So, thanks to Achim, in the rmrk-tools repo, you can use: https://github.com/rmrk-team/rmrk-tools#fetchremarks fetchRemarks(api, to, from, prefixes); method call It's not pretty but it's a start: ...
rarara's user avatar
  • 141
2 votes
Accepted

get bonded balance using API

To get a bunch of metadata about the a users staking configuration, you can do: api.derive.staking.account(stash_account_address) This returns an object like: "{ \"nextSessionIds\": [...
Shawn Tabrizi's user avatar
  • 16k
2 votes

How to get StorageKey associated with an address?

Great question! If you have a prefix of a storage key that you are looking for, you can specify in the first argument like so: Note that if you specify 0x you will get all the keys! If you want to ...
Bruno's user avatar
  • 8,365
2 votes

How can I listen to new receive transfer?

I would suggest splitting your questions into two - it is somewhat difficult to answer 2 completely different questions coherently in one. First off, you mention "hash" - be aware that ...
Barto's user avatar
  • 584

Only top scored, non community-wiki answers of a minimum length are eligible