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
The second line above deconstructs several utilities from nearAPI that you will use to interact with the blockchain.
50
+
The destructured utilities from near-api-js that you will use to interact with the blockchain:
52
51
53
-
-`connect` - create a connection to NEAR passing configuration variables
52
+
-`Near` - create a connection to NEAR passing configuration variables
53
+
-`Account` - creates an account object for interacting with the blockchain
54
54
-`KeyPair` - creates a keyPair from the private key you'll provide in an `.env` file
55
55
-`keyStores` - stores the keyPair that you will create from the private key and used to sign Transactions
56
56
-`utils` - used to format NEAR amounts
@@ -72,7 +72,7 @@ When sending NEAR tokens (Ⓝ) during a transaction, the amount needs to be conv
72
72
- To perform this you will use the [`near-api-js`](https://github.com/near/near-api-js) method [`parseNearAmount()`](https://github.com/near/near-api-js/blob/d4d4cf1ac3182fa998b1e004e6782219325a641b/src/utils/format.ts#L53-L63) (located in `utils/format`)
@@ -178,7 +178,7 @@ When sending NEAR tokens (Ⓝ) during a transaction, the amount needs to be conv
178
178
- To perform this you will use the [`near-api-js`](https://github.com/near/near-api-js) method [`parseNearAmount()`](https://github.com/near/near-api-js/blob/d4d4cf1ac3182fa998b1e004e6782219325a641b/src/utils/format.ts#L53-L63) (located in `utils/format`)
- There are currently eight supported `Action` types. [[see here]](/protocol/transaction-anatomy#actions)
311
313
- For this example, we are using `Transfer`
312
-
- This transfer action can be created using the [imported `nearAPI` object](#imports) and the [formatted Ⓝ amount](#formatting-token-amounts) created earlier.
314
+
- This transfer action can be created using the [imported `transactions` object](#imports) and the [formatted Ⓝ amount](#formatting-token-amounts) created earlier.
[[click here]](https://github.com/near/near-api-js/blob/d4d4cf1ac3182fa998b1e004e6782219325a641b/src/transaction.ts#L70-L72) to view source for `transfer()`.
319
321
320
322
### 6 `blockHash`
321
323
322
324
- Each transaction requires a current block hash (within 24hrs) to prove that the transaction was created recently.
323
-
- Hash must be converted to an array of bytes using the `base_decode` method found in [`nearAPI`](#imports).
325
+
- Hash must be converted to an array of bytes using the `base_decode` method found in [`utils`](#imports).
@@ -378,12 +380,12 @@ const serializedTxHash = new Uint8Array(sha256.sha256.array(serializedTx));
378
380
constsignature=keyPair.sign(serializedTxHash);
379
381
```
380
382
381
-
4. Construct the signed transaction using `near-api-js`[SignedTransaction class](https://github.com/near/near-api-js/blob/d4d4cf1ac3182fa998b1e004e6782219325a641b/src/transaction.ts#L112-L123).
383
+
4. Construct the signed transaction using near-api-js [SignedTransaction class](https://github.com/near/near-api-js/blob/d4d4cf1ac3182fa998b1e004e6782219325a641b/src/transaction.ts#L112-L123).
@@ -395,7 +397,7 @@ const signedTransaction = new nearAPI.transactions.SignedTransaction({
395
397
Final step is to encode and send the transaction.
396
398
397
399
- First we serialize transaction into [Borsh](https://borsh.io/), and store the result as `signedSerializedTx`. _(required for all transactions)_
398
-
- Then we send the transaction via [RPC call](/api/rpc/introduction) using the `sendJsonRpc()` method nested inside [`near`](#setting-up-a-connection-to-near).
400
+
- Then we send the transaction via [RPC call](/api/rpc/introduction) using the `sendJsonRpc()` method nested inside [`provider`](#setting-up-a-connection-to-near).
399
401
400
402
```js
401
403
// encodes transaction to serialized Borsh (required for all transactions)
0 commit comments