Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/developers/developer-reference/sc-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Annotations (also known as Rust "attributes") are the bread and butter of the `m

One of the main purposes of the framework is to make the code as readable and concise as possible, and annotations are the path to get there.

For an introduction, check out [the Crowdfunding tutorial](/developers/tutorials/crowdfunding-p1). This page is supposed to be a complete index of all annotations that can be encountered in smart contracts.
For an introduction, check out [the Crowdfunding tutorial](/developers/tutorials/crowdfunding/crowdfunding-p1). This page is supposed to be a complete index of all annotations that can be encountered in smart contracts.

[comment]: # (mx-exclude-context)

Expand Down
2 changes: 1 addition & 1 deletion docs/developers/tutorials/chain-simulator-adder.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ One of the best parts about using the Chain Simulator with your interactor is th
Before you start writing tests, ensure that your `Cargo.toml` file includes the `chain-simulator-tests` feature flag, which is necessary to run them.
:::

In the initial template generated in [Step 1](./chain-simulator-adder.md#step-1-start-from-template), you’ll see that the `chain-simulator-tests` feature is already included. So, your interactor crate’s `Cargo.toml` file should look like this:
In the initial template generated in [Step 1](./chain-simulator-adder.md#step-1-start-from-the-template), you’ll see that the `chain-simulator-tests` feature is already included. So, your interactor crate’s `Cargo.toml` file should look like this:

```toml
[package]
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/tutorials/wallet-connect-v2-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Using `@multiversx/sdk-dapp` >= `2.2.8` or `@elrondnetwork/dapp-core` >= `2.0.0`

WalletConnect 2.0 is already integrated, only not enabled by default.

Follow [these steps](/sdk-and-tools/sdk-dapp/#walletconnect-setup) to generate and add a `walletConnectV2ProjectId`
Follow [these steps](/sdk-and-tools/sdk-js/cookbook/wallets/walletconnect-login#configuring-the-project-id) to generate and add a `walletConnectV2ProjectId`

---

Expand Down
2 changes: 1 addition & 1 deletion docs/sdk-and-tools/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You might also want to have a look over [**xSuite**](https://xsuite.dev), a tool

| Name | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [sdk-py](/sdk-and-tools/sdk-py/#sdk-py-the-python-libraries) | Python SDK that can be used to create wallets, create and send transactions, interact with Smart Contracts and with the MultiversX Network in general. |
| [sdk-py](/sdk-and-tools/sdk-py#overview) | Python SDK that can be used to create wallets, create and send transactions, interact with Smart Contracts and with the MultiversX Network in general. |

[comment]: # (mx-context-auto)

Expand Down
75 changes: 75 additions & 0 deletions docs/sdk-and-tools/sdk-js/cookbook/accounts/save-key-value.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Save key-value data to an account
description: Save key-value pairs in an account's on-chain storage with sdk-core's AccountController or AccountTransactionsFactory.
difficulty: intermediate
est_minutes: 8
artifact: reference
sdk_versions:
sdk-core: "15.4.1"
tags:
- sdk-core
- account
- account-storage
- transaction
- devnet
---

#### Saving a key-value pair to an account using the controller
You can find more information [here](/developers/account-storage) regarding the account storage.

```js
{
// create the entrypoint and the account controller
const entrypoint = new DevnetEntrypoint();
const controller = entrypoint.createAccountController();

const filePath = path.join("../src", "testdata", "testwallets", "alice.pem");
const alice = await Account.newFromPem(filePath);

// creating the key-value pairs we want to save
const keyValuePairs = new Map([[Buffer.from("key0"), Buffer.from("value0")]]);

// fetch the nonce of the network
alice.nonce = await entrypoint.recallAccountNonce(alice.address);

const transaction = await controller.createTransactionForSavingKeyValue(alice, alice.getNonceThenIncrement(), {
keyValuePairs: keyValuePairs,
});

// sending the transaction
const txHash = await entrypoint.sendTransaction(transaction);
}
```

#### Saving a key-value pair to an account using the factory
```js
{
// create the entrypoint and the account factory
const entrypoint = new DevnetEntrypoint();
const factory = entrypoint.createAccountTransactionsFactory();

// create the account to guard
const filePath = path.join("../src", "testdata", "testwallets", "alice.pem");
const alice = await Account.newFromPem(filePath);

// creating the key-value pairs we want to save
const keyValuePairs = new Map([[Buffer.from("key0"), Buffer.from("value0")]]);

const transaction = await factory.createTransactionForSavingKeyValue(alice.address, {
keyValuePairs: keyValuePairs,
});

// fetch the nonce of the network
alice.nonce = await entrypoint.recallAccountNonce(alice.address);

// set the nonce
transaction.nonce = alice.getNonceThenIncrement();

// sign the transaction
transaction.signature = await alice.signTransaction(transaction);

// sending the transaction
const txHash = await entrypoint.sendTransaction(transaction);
}
```

Loading
Loading