@@ -16,23 +16,27 @@ tags:
1616### Fetching the network config
1717
1818``` js
19+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
20+
1921{
2022 const entrypoint = new DevnetEntrypoint ();
2123 const networkProvider = entrypoint .createNetworkProvider ();
2224
23- const networkConfig = networkProvider .getNetworkConfig ();
25+ const networkConfig = await networkProvider .getNetworkConfig ();
2426}
2527```
2628
2729### Fetching the network status
2830
2931``` js
32+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
33+
3034{
3135 const entrypoint = new DevnetEntrypoint ();
3236 const networkProvider = entrypoint .createNetworkProvider ();
3337
34- const metaNetworkStatus = networkProvider .getNetworkStatus (); // fetches status from metachain
35- const networkStatus = networkProvider .getNetworkStatus (); // fetches status from shard one
38+ const metaNetworkStatus = await networkProvider .getNetworkStatus (); // fetches status from metachain
39+ const shardOneNetworkStatus = await networkProvider .getNetworkStatus (1 ); // fetches status from shard one
3640}
3741```
3842
@@ -43,6 +47,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in
4347
4448#### Fetching a block using the ** API**
4549``` js
50+ import { ApiNetworkProvider } from " @multiversx/sdk-core" ;
51+
4652{
4753 const api = new ApiNetworkProvider (" https://devnet-api.multiversx.com" );
4854 const blockHash = " 1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a" ;
@@ -53,6 +59,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in
5359Additionally, we can fetch the latest block from the network:
5460
5561``` js
62+ import { ApiNetworkProvider } from " @multiversx/sdk-core" ;
63+
5664{
5765 const api = new ApiNetworkProvider (" https://devnet-api.multiversx.com" );
5866 const latestBlock = await api .getLatestBlock ();
@@ -63,27 +71,33 @@ Additionally, we can fetch the latest block from the network:
6371
6472When using the proxy, we have to provide the shard, as well.
6573``` js
74+ import { ProxyNetworkProvider } from " @multiversx/sdk-core" ;
75+
6676{
67- const proxy = new ProxyNetworkProvider (" https://devnet-api .multiversx.com" );
77+ const proxy = new ProxyNetworkProvider (" https://devnet-gateway .multiversx.com" );
6878 const blockHash = " 1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a" ;
69- const block = proxy .getBlock ({ blockHash, shard: 1 });
79+ const block = await proxy .getBlock ({ blockHash, shard: 1 });
7080}
7181```
7282
7383We can also fetch the latest block from the network.
7484By default, the shard will be the metachain, but we can specify a different shard if needed.
7585
7686``` js
87+ import { ProxyNetworkProvider } from " @multiversx/sdk-core" ;
88+
7789{
78- const proxy = new ProxyNetworkProvider (" https://devnet-api .multiversx.com" );
79- const latestBlock = proxy .getLatestBlock ();
90+ const proxy = new ProxyNetworkProvider (" https://devnet-gateway .multiversx.com" );
91+ const latestBlock = await proxy .getLatestBlock ();
8092}
8193```
8294
8395### Fetching an Account
8496To 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.
8597
8698``` js
99+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
100+
87101{
88102 const entrypoint = new DevnetEntrypoint ();
89103 const api = entrypoint .createNetworkProvider ();
@@ -96,6 +110,8 @@ To fetch an account, we need its address. Once we have the address, we create an
96110We can also fetch an account's storage, allowing us to retrieve all key-value pairs saved for that account.
97111
98112``` js
113+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
114+
99115{
100116 const entrypoint = new DevnetEntrypoint ();
101117 const api = entrypoint .createNetworkProvider ();
@@ -107,6 +123,8 @@ We can also fetch an account's storage, allowing us to retrieve all key-value pa
107123If we only want to fetch a specific key, we can do so as follows:
108124
109125``` js
126+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
127+
110128{
111129 const entrypoint = new DevnetEntrypoint ();
112130 const api = entrypoint .createNetworkProvider ();
@@ -124,11 +142,13 @@ To implement this, we need to define the condition to check each time the accoun
124142Keep in mind that this method has a default timeout, which can be adjusted using the ` AwaitingOptions ` class.
125143
126144``` js
145+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
146+
127147{
128148 const entrypoint = new DevnetEntrypoint ();
129149 const api = entrypoint .createNetworkProvider ();
130150
131- const condition = (account : any ) => {
151+ const condition = (account ) => {
132152 return account .balance >= 7000000000000000000n ; // 7 EGLD
133153 };
134154 const alice = Address .newFromBech32 (" erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" );
@@ -142,6 +162,8 @@ To execute transactions, we use the network providers to broadcast them to the n
142162#### Sending a Transaction
143163
144164``` js
165+ import { Address , DevnetEntrypoint , Transaction } from " @multiversx/sdk-core" ;
166+
145167{
146168 const entrypoint = new DevnetEntrypoint ();
147169 const api = entrypoint .createNetworkProvider ();
@@ -164,6 +186,8 @@ To execute transactions, we use the network providers to broadcast them to the n
164186
165187#### Sending multiple transactions
166188``` js
189+ import { Address , DevnetEntrypoint , Transaction } from " @multiversx/sdk-core" ;
190+
167191{
168192 const entrypoint = new DevnetEntrypoint ();
169193 const api = entrypoint .createNetworkProvider ();
@@ -210,6 +234,8 @@ To execute transactions, we use the network providers to broadcast them to the n
210234A 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.
211235
212236``` js
237+ import { Address , DevnetEntrypoint , Transaction } from " @multiversx/sdk-core" ;
238+
213239{
214240 const entrypoint = new DevnetEntrypoint ();
215241 const api = entrypoint .createNetworkProvider ();
@@ -233,6 +259,8 @@ A transaction can be simulated before being sent for processing by the network.
233259Before sending a transaction to the network for processing, you can retrieve the estimated gas limit required for the transaction to be executed.
234260
235261``` js
262+ import { Address , DevnetEntrypoint , Transaction } from " @multiversx/sdk-core" ;
263+
236264{
237265 const entrypoint = new DevnetEntrypoint ();
238266 const api = entrypoint .createNetworkProvider ();
@@ -259,6 +287,8 @@ Before sending a transaction to the network for processing, you can retrieve the
259287After 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.
260288
261289``` js
290+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
291+
262292{
263293 const entrypoint = new DevnetEntrypoint ();
264294 const api = entrypoint .createNetworkProvider ();
@@ -272,11 +302,13 @@ After sending a transaction, you may want to wait until it is processed before p
272302Similar to accounts, we can wait until a transaction meets a specific condition.
273303
274304``` js
305+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
306+
275307{
276308 const entrypoint = new DevnetEntrypoint ();
277309 const api = entrypoint .createNetworkProvider ();
278310
279- const condition = (txOnNetwork : any ) => ! txOnNetwork .status .isSuccessful ();
311+ const condition = (txOnNetwork ) => txOnNetwork .status .isSuccessful ();
280312
281313 const txHash = " exampletransactionhash" ;
282314 const transactionOnNetwork = await api .awaitTransactionOnCondition (txHash, condition);
@@ -287,6 +319,8 @@ Similar to accounts, we can wait until a transaction meets a specific condition.
287319After 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.
288320
289321``` js
322+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
323+
290324{
291325 const entrypoint = new DevnetEntrypoint ();
292326 const api = entrypoint .createNetworkProvider ();
@@ -300,6 +334,8 @@ After sending a transaction, you may want to wait until it is processed before p
300334After sending a transaction, we can fetch it from the network using the transaction hash, which we receive after broadcasting the transaction.
301335
302336``` js
337+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
338+
303339{
304340 const entrypoint = new DevnetEntrypoint ();
305341 const api = entrypoint .createNetworkProvider ();
@@ -313,6 +349,8 @@ After sending a transaction, we can fetch it from the network using the transact
313349We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by providing the account's address and the token identifier.
314350
315351``` js
352+ import { Address , DevnetEntrypoint , Token } from " @multiversx/sdk-core" ;
353+
316354{
317355 const entrypoint = new DevnetEntrypoint ();
318356 const api = entrypoint .createNetworkProvider ();
@@ -330,6 +368,8 @@ We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by prov
330368Fetches all fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using ` doGetGeneric ` .
331369
332370``` js
371+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
372+
333373{
334374 const entrypoint = new DevnetEntrypoint ();
335375 const api = entrypoint .createNetworkProvider ();
@@ -343,6 +383,8 @@ Fetches all fungible tokens held by an account. Note that this method does not h
343383Fetches all non-fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using ` doGetGeneric ` .
344384
345385``` js
386+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
387+
346388{
347389 const entrypoint = new DevnetEntrypoint ();
348390 const api = entrypoint .createNetworkProvider ();
@@ -356,6 +398,8 @@ Fetches all non-fungible tokens held by an account. Note that this method does n
356398If we want to fetch the metadata of a token (e.g., owner, decimals, etc.), we can use the following methods:
357399
358400``` js
401+ import { DevnetEntrypoint } from " @multiversx/sdk-core" ;
402+
359403{
360404 const entrypoint = new DevnetEntrypoint ();
361405 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
372416Smart 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:
373417
374418``` js
419+ import { Address , DevnetEntrypoint , SmartContractQuery } from " @multiversx/sdk-core" ;
420+
375421{
376422 const entrypoint = new DevnetEntrypoint ();
377423 const api = entrypoint .createNetworkProvider ();
@@ -390,14 +436,15 @@ The methods exposed by the `ApiNetworkProvider` or `ProxyNetworkProvider` are th
390436Let’s assume we want to retrieve all the transactions sent by Alice in which the ` delegate ` function was called.
391437
392438``` js
439+ import { Address , DevnetEntrypoint } from " @multiversx/sdk-core" ;
440+
393441{
394442 const entrypoint = new DevnetEntrypoint ();
395443 const api = entrypoint .createNetworkProvider ();
396444
397445 const alice = Address .newFromBech32 (" erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" );
398- const url = ` transactions /${ alice .toBech32 ()} ?function=delegate` ;
446+ const url = ` accounts /${ alice .toBech32 ()} /transactions ?function=delegate` ;
399447
400448 const response = await api .doGetGeneric (url);
401449}
402450```
403-
0 commit comments