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
Copy file name to clipboardExpand all lines: docs/pages/ink.md
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,9 @@ So to generate the types for a contract, run the `ink add` command:
29
29
> pnpm papi ink add "path to .contract or .json metadata file"
30
30
```
31
31
32
-
This will add the contract to the `.papi` subfolder, and generate the type descriptors for the ink! contract. These can be found in `@polkadot-api/descriptors` within an object named "contracts".
32
+
This will add the contract to the `.papi` subfolder, and generate the type descriptors for the ink! contract. These can be found in `@polkadot-api/descriptors` within an object named "contracts", and are keyed by contract name.
33
+
34
+
The contract name by default is the one specified in the contract's metadata, but if needed it can be overriden with the `--key` parameter in `ink add`.
33
35
34
36
The generated code contains all the types, and also the required info from the metadata to encode and decode values.
Copy file name to clipboardExpand all lines: docs/pages/sdks/ink-sdk.md
+29-11Lines changed: 29 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Ink! SDK
2
2
3
-
The Ink! SDK is a library for interacting with smart contracts, built on top of the [Ink! Client](/ink).
3
+
The Ink! SDK is a library for interacting with smart contracts, built on top of the [Ink! Client](/ink). It supports both pallet contracts (for ink!v5 or below) and pallet revive (for ink!v6 and above).
4
4
5
5
## Getting Started
6
6
@@ -10,32 +10,38 @@ Install the sdk through your package manager:
10
10
pnpm i @polkadot-api/sdk-ink
11
11
```
12
12
13
-
Begin by generating the type definitions for your chain and contract. For example, using a PSP22 contract on the test Aleph Zero network:
13
+
Begin by generating the type definitions for your chain and contract. For example, using a PSP22 contract on the test Paseo Pop network:
pnpm papi add -w wss://rpc1.paseo.popnetwork.xyz pop
17
17
pnpm papi ink add ./psp22.json # Path to the .contract or .json metadata file
18
18
```
19
19
20
+
:::note
21
+
You can find a working example in [the ink-sdk repo](https://github.com/polkadot-api/papi-sdks/tree/main/examples/ink-playground). An example PSP22 contract and its metadata is available in the `./contracts/psp22_mod` folder.
22
+
:::
23
+
20
24
This process uses the name defined in the contract metadata to export it as a property of `contracts` in `@polkadot-api/descriptors`. For this example, the contract name is "psp22." You can now instantiate the Ink! SDK:
When using a ink!v6 contract, use `createReviveSdk` instead of `createInkSdk`. Both have the same API, but revive sdk uses the pallet-revive instead, which is where ink!v6 contracts are deployed.
43
+
:::
44
+
39
45
The SDK provides two main functions for different workflows:
40
46
41
47
-`getDeployer(code: Binary)`: Returns an API for deploying contracts.
@@ -56,7 +62,7 @@ The deployer API supports two methods: one for dry-running deployments and anoth
56
62
57
63
When deploying, the SDK calculates all parameters, requiring only the constructor arguments defined in the contract.
58
64
59
-
To calculate the gas limit required, the SDK also needs the origin account the transaction will be sent from. So it either uses the origin account or the gas limit if you already have it.
65
+
To calculate the gas limit and storage deposit limit required, the SDK also needs the origin account the transaction will be sent from. So it either uses the origin account or the gas limit if you already have it.
60
66
61
67
The "salt" parameter ensures unique contract deployments. By default, it is empty, but you can provide a custom value for deploying multiple instances of the same contract.
0 commit comments