You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rationale behind the offline api is to allow consumers to do certain actions with PAPI without the need of a provider. As expected, this client is more limited than the regular [`PolkadotClient`](/client).
4
+
5
+
Let's see an example first of all:
6
+
7
+
```typescript
8
+
import { getOfflineApi } from"polkadot-api"
9
+
import { dotDescriptors } from"@polkadot-api/descriptors"// you'll need them!
10
+
11
+
const offline =awaitgetOfflineApi(dotDescriptors) // it is async!
12
+
13
+
// metadata constants can be easily accessed
14
+
const prefix =api.constants.System.SS58Prefix// directly the value; e.g. `0`
// we can sign txs, but we need to add more stuff than usual!
34
+
const signedTx =awaittx2.sign(signer, {
35
+
nonce: 24, // nonce is always compulsory
36
+
mortality: { mortal: false }, // and mortality!
37
+
})
38
+
```
39
+
40
+
## Constants
41
+
42
+
Constants can be accessed easily having the metadata. `api.constants.Pallet.Entry` already gives the decoded value.
43
+
44
+
## Transactions
45
+
46
+
This is the main usecase of offline api. It allows to create and encode transactions, and even sign them.
47
+
The transactions are created in the exact same way as in the regular API ([see docs](/typed/tx)). Nevertheless, only a subset of the fields are exposed:
48
+
49
+
-`decodedCall`: it enables to get the _PAPI decoded_ transaction. It is helpful to create other txs that require them as a parameter (e.g. `Utility.batch`).
50
+
-`encodedData`: a `Binary` with the encoded call data.
51
+
-`sign`: it takes the same arguments as the regular API, but there are two compulsory signed extensions:
52
+
-`nonce`: nonce cannot be retrieved anymore from the chain, and therefore has to be passed
53
+
-`mortality`: transactions can be signed either mortal or immortal. In case the tx were to be mortal, the block information has to be passed as well.
Copy file name to clipboardExpand all lines: docs/pages/requirements.md
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ PAPI is designed to work flawlessly with almost any Polkadot-like chain. Even th
6
6
7
7
### NodeJS
8
8
9
-
PAPI is developed using the latest NodeJS LTS (currently `20.x`). The minimum required version is `20.6.0`, while we recommend the latest available release.
9
+
PAPI is developed using the latest NodeJS LTS (currently `22.x`). The minimum required version is `20.6.0`, while we recommend the latest available release.
10
10
11
11
### Bun
12
12
@@ -70,10 +70,6 @@ Besides that, Polkadot-API requires runtimes to implement some basic runtime cal
70
70
- In order to get the metadata, it needs `Metadata_metadata_versions` and `Metadata_metadata_at_version`. If they are not present, then `Metadata_metadata` needs to be there and answer a `v14` Metadata.
71
71
- To create and broadcast transactions, Polkadot-API needs `AccountNonceApi_account_nonce` and `TaggedTransactionQueue_validate_transaction`. To estimate the fees, it also requires `TransactionPaymentApi_query_info`.
72
72
73
-
In order to create transactions as well, the following storage entry is required for obtaining the genesis block-hash:
74
-
75
-
-`System.BlockHash`
76
-
77
-
And the following constant:
73
+
In order to create transactions as well, the following constant is required:
78
74
79
75
-`System.Version`, having `spec_version` and `transaction_version` fields.
0 commit comments