Skip to content

Commit

Permalink
Merge pull request #970 from multiversx/TOOL-238-update-packages-on-s…
Browse files Browse the repository at this point in the history
…dk-js-examples

Update sdk-js cookbook
  • Loading branch information
danielailie committed Sep 4, 2024
2 parents a6b3f4a + d2afba8 commit 8266a1e
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions docs/sdk-and-tools/sdk-js/sdk-js-cookbook-v13.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@ This page will guide you through the process of handling common tasks using **sd
This cookbook makes use of `sdk-js v13`. In order to migrate from `sdk-js v12.x` to `sdk-js v13`, please also follow [the migration guide](https://github.com/multiversx/mx-sdk-js-core/issues/392).
:::

:::important
This page is a work in progress. Please check back later for more content.
:::

## Creating network providers

Creating an API provider:

```js
import { ApiNetworkProvider } from "@multiversx/sdk-network-providers";

const apiNetworkProvider = new ApiNetworkProvider("https://devnet-api.multiversx.com");
const apiNetworkProvider = new ApiNetworkProvider("https://devnet-api.multiversx.com", { clientName: "multiversx-your-client-name" });
```

Creating a Proxy provider:

```js
import { ProxyNetworkProvider } from "@multiversx/sdk-network-providers";

const proxyNetworkProvider = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com");
const proxyNetworkProvider = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com", { clientName: "multiversx-your-client-name" });
```

Use the classes from `@multiversx/sdk-network-providers` **only as a starting point**.
Expand Down Expand Up @@ -201,7 +197,7 @@ Generally speaking, in order to create transactions that transfer native tokens

:::note
In `sdk-core v13`, the [`TransferTransactionsFactory`](https://multiversx.github.io/mx-sdk-js-core/v13/classes/TransferTransactionsFactory.html) class was extended with new methods,
to be aligned with the [SDKs specs](https://github.com/multiversx/mx-sdk-specs/blob/main/core/transactions-factories/transfer_transactions_factory).
to be aligned with the [SDKs specs](https://github.com/multiversx/mx-sdk-specs/blob/main/core/transactions-factories/transfer_transactions_factory.md).
The old, legacy methods are still available (see below), thus existing client code isn't affected.
:::

Expand Down Expand Up @@ -343,7 +339,7 @@ import BigNumber from "bignumber.js";

BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_FLOOR });

console.log("Format using bignumber.js:",new BigNumber("1500000000000000000").shiftedBy(-18).toFixed(4));
console.log("Format using bignumber.js:", new BigNumber("1500000000000000000").shiftedBy(-18).toFixed(4));
```

You can parse amounts using `parseAmount` from `sdk-dapp`:
Expand Down Expand Up @@ -1073,7 +1069,3 @@ transaction.signature = await signer.sign(bytesToSign);
:::note
If you'd like to learn more about hash signing, please refer to the overview on [signing transactions](/developers/signing-transactions).
:::

:::important
This page is a work in progress. Please check back later for more content.
:::

0 comments on commit 8266a1e

Please sign in to comment.