From 0579eb8829c10345348a965ce4b371e734cc1915 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Wed, 12 Aug 2026 16:14:45 +0300 Subject: [PATCH 1/2] fixes --- .../fetching-data-from-network/reference.mdx | 69 ++++++++++++++++--- .../multisig/deploy-multisig-contract.mdx | 24 +++++-- .../cookbook/multisig/propose-action.mdx | 2 +- package.json | 2 +- 4 files changed, 77 insertions(+), 20 deletions(-) diff --git a/docs/sdk-and-tools/sdk-js/cookbook/fetching-data-from-network/reference.mdx b/docs/sdk-and-tools/sdk-js/cookbook/fetching-data-from-network/reference.mdx index 297d42bc..ca279f41 100644 --- a/docs/sdk-and-tools/sdk-js/cookbook/fetching-data-from-network/reference.mdx +++ b/docs/sdk-and-tools/sdk-js/cookbook/fetching-data-from-network/reference.mdx @@ -16,23 +16,27 @@ tags: ### Fetching the network config ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const networkProvider = entrypoint.createNetworkProvider(); - const networkConfig = networkProvider.getNetworkConfig(); + const networkConfig = await networkProvider.getNetworkConfig(); } ``` ### Fetching the network status ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const networkProvider = entrypoint.createNetworkProvider(); - const metaNetworkStatus = networkProvider.getNetworkStatus(); // fetches status from metachain - const networkStatus = networkProvider.getNetworkStatus(); // fetches status from shard one + const metaNetworkStatus = await networkProvider.getNetworkStatus(); // fetches status from metachain + const shardOneNetworkStatus = await networkProvider.getNetworkStatus(1); // fetches status from shard one } ``` @@ -43,6 +47,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in #### Fetching a block using the **API** ```js +import { ApiNetworkProvider } from "@multiversx/sdk-core"; + { const api = new ApiNetworkProvider("https://devnet-api.multiversx.com"); const blockHash = "1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a"; @@ -53,6 +59,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in Additionally, we can fetch the latest block from the network: ```js +import { ApiNetworkProvider } from "@multiversx/sdk-core"; + { const api = new ApiNetworkProvider("https://devnet-api.multiversx.com"); const latestBlock = await api.getLatestBlock(); @@ -63,10 +71,12 @@ Additionally, we can fetch the latest block from the network: When using the proxy, we have to provide the shard, as well. ```js +import { ProxyNetworkProvider } from "@multiversx/sdk-core"; + { - const proxy = new ProxyNetworkProvider("https://devnet-api.multiversx.com"); + const proxy = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com"); const blockHash = "1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a"; - const block = proxy.getBlock({ blockHash, shard: 1 }); + const block = await proxy.getBlock({ blockHash, shard: 1 }); } ``` @@ -74,9 +84,11 @@ We can also fetch the latest block from the network. By default, the shard will be the metachain, but we can specify a different shard if needed. ```js +import { ProxyNetworkProvider } from "@multiversx/sdk-core"; + { - const proxy = new ProxyNetworkProvider("https://devnet-api.multiversx.com"); - const latestBlock = proxy.getLatestBlock(); + const proxy = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com"); + const latestBlock = await proxy.getLatestBlock(); } ``` @@ -84,6 +96,8 @@ By default, the shard will be the metachain, but we can specify a different shar To fetch an account, we need its address. Once we have the address, we create an `Address` object and pass it as an argument to the method. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -96,6 +110,8 @@ To fetch an account, we need its address. Once we have the address, we create an We can also fetch an account's storage, allowing us to retrieve all key-value pairs saved for that account. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -107,6 +123,8 @@ We can also fetch an account's storage, allowing us to retrieve all key-value pa If we only want to fetch a specific key, we can do so as follows: ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -124,11 +142,13 @@ To implement this, we need to define the condition to check each time the accoun Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); - const condition = (account: any) => { + const condition = (account) => { return account.balance >= 7000000000000000000n; // 7 EGLD }; const alice = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); @@ -142,6 +162,8 @@ To execute transactions, we use the network providers to broadcast them to the n #### Sending a Transaction ```js +import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -164,6 +186,8 @@ To execute transactions, we use the network providers to broadcast them to the n #### Sending multiple transactions ```js +import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -210,6 +234,8 @@ To execute transactions, we use the network providers to broadcast them to the n A transaction can be simulated before being sent for processing by the network. This is primarily used for smart contract calls, allowing you to preview the results produced by the smart contract. ```js +import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -233,6 +259,8 @@ A transaction can be simulated before being sent for processing by the network. Before sending a transaction to the network for processing, you can retrieve the estimated gas limit required for the transaction to be executed. ```js +import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -259,6 +287,8 @@ Before sending a transaction to the network for processing, you can retrieve the After sending a transaction, you may want to wait until it is processed before proceeding with another action. Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class. ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -272,11 +302,13 @@ After sending a transaction, you may want to wait until it is processed before p Similar to accounts, we can wait until a transaction meets a specific condition. ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); - const condition = (txOnNetwork: any) => !txOnNetwork.status.isSuccessful(); + const condition = (txOnNetwork) => txOnNetwork.status.isSuccessful(); const txHash = "exampletransactionhash"; const transactionOnNetwork = await api.awaitTransactionOnCondition(txHash, condition); @@ -287,6 +319,8 @@ Similar to accounts, we can wait until a transaction meets a specific condition. After sending a transaction, you may want to wait until it is processed before proceeding with another action. Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class. ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -300,6 +334,8 @@ After sending a transaction, you may want to wait until it is processed before p After sending a transaction, we can fetch it from the network using the transaction hash, which we receive after broadcasting the transaction. ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -313,6 +349,8 @@ After sending a transaction, we can fetch it from the network using the transact We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by providing the account's address and the token identifier. ```js +import { Address, DevnetEntrypoint, Token } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -330,6 +368,8 @@ We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by prov Fetches all fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using `doGetGeneric`. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -343,6 +383,8 @@ Fetches all fungible tokens held by an account. Note that this method does not h Fetches all non-fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using `doGetGeneric`. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -356,6 +398,8 @@ Fetches all non-fungible tokens held by an account. Note that this method does n If we want to fetch the metadata of a token (e.g., owner, decimals, etc.), we can use the following methods: ```js +import { DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -372,6 +416,8 @@ If we want to fetch the metadata of a token (e.g., owner, decimals, etc.), we ca Smart contract queries, or view functions, are endpoints that only read data from the contract. To send a query to the observer nodes, we can proceed as follows: ```js +import { Address, DevnetEntrypoint, SmartContractQuery } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); @@ -390,14 +436,15 @@ The methods exposed by the `ApiNetworkProvider` or `ProxyNetworkProvider` are th Let’s assume we want to retrieve all the transactions sent by Alice in which the `delegate` function was called. ```js +import { Address, DevnetEntrypoint } from "@multiversx/sdk-core"; + { const entrypoint = new DevnetEntrypoint(); const api = entrypoint.createNetworkProvider(); const alice = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); - const url = `transactions/${alice.toBech32()}?function=delegate`; + const url = `accounts/${alice.toBech32()}/transactions?function=delegate`; const response = await api.doGetGeneric(url); } ``` - diff --git a/docs/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract.mdx b/docs/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract.mdx index 96e25942..0d0af76c 100644 --- a/docs/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract.mdx +++ b/docs/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract.mdx @@ -24,9 +24,14 @@ These operations can be performed using both the **controller** and the **factor #### Deploying a Multisig Smart Contract using the controller ```js +import * as fs from 'fs'; +import * as path from 'path'; +import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core'; + { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' }); + const abi = Abi.create(JSON.parse(abiJson)); + const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm')); // create the entrypoint and the multisig controller const entrypoint = new DevnetEntrypoint(); @@ -44,7 +49,7 @@ These operations can be performed using both the **controller** and the **factor alice.address, Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"), ], - bytecode: bytecode.valueOf(), + bytecode, gasLimit: 100000000n, }); @@ -54,15 +59,20 @@ These operations can be performed using both the **controller** and the **factor // wait for transaction completion, extract multisig contract's address const outcome = await controller.awaitCompletedDeploy(txHash); - const contractAddress = outcome[0].contractAddress; + const contractAddress = outcome.contracts[0].address; } ``` #### Deploying a Multisig Smart Contract using the factory ```js +import * as fs from 'fs'; +import * as path from 'path'; +import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core'; + { - const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json"); - const bytecode = await loadContractCode("src/testdata/multisig-full.wasm"); + const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' }); + const abi = Abi.create(JSON.parse(abiJson)); + const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm')); // create the entrypoint and the multisig factory const entrypoint = new DevnetEntrypoint(); @@ -80,7 +90,7 @@ These operations can be performed using both the **controller** and the **factor alice.address, Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"), ], - bytecode: bytecode.valueOf(), + bytecode, gasLimit: 100000000n, }); diff --git a/docs/sdk-and-tools/sdk-js/cookbook/multisig/propose-action.mdx b/docs/sdk-and-tools/sdk-js/cookbook/multisig/propose-action.mdx index 3f2300bc..47db140b 100644 --- a/docs/sdk-and-tools/sdk-js/cookbook/multisig/propose-action.mdx +++ b/docs/sdk-and-tools/sdk-js/cookbook/multisig/propose-action.mdx @@ -592,5 +592,5 @@ transfer with no function call adds nothing after it. Pass `optGasLimit` / is what happens to the action id this recipe creates. - [Read a multisig's state](/sdk-and-tools/sdk-js/cookbook/multisig/read-multisig-state) checks roles, quorum, and pending actions before proposing. -- [Deploy a smart contract](/sdk-and-tools/sdk-js/cookbook/smart-contracts-deploy/deploy-contract) +- [Deploy a smart contract](/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract) is how the multisig itself, being a contract, gets deployed. diff --git a/package.json b/package.json index 5eef9beb..af733970 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "generate:llms": "node scripts/generate-llms-txt.js", - "generate:md-urls": "node scripts/generate-md-urls.js", + "generate:md-urls": "node scripts/generate-md-urls.js && node scripts/generate-md-urls.js", "generate:cookbook": "node scripts/generate-cookbook-manifest.js" }, "dependencies": { From cb716b2cebb972036f3ffb91d481195329c4cc8d Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Wed, 12 Aug 2026 16:41:48 +0300 Subject: [PATCH 2/2] fix script line --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af733970..c125f1cf 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "generate:llms": "node scripts/generate-llms-txt.js", - "generate:md-urls": "node scripts/generate-md-urls.js && node scripts/generate-md-urls.js", + "generate:md-urls": "npm run generate:cookbook && node scripts/generate-md-urls.js", "generate:cookbook": "node scripts/generate-cookbook-manifest.js" }, "dependencies": {