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
Copy file name to clipboardExpand all lines: apps/docs/content/docs/apis/txbuilder/basics.mdx
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ icon: PaperAirplaneIcon
5
5
---
6
6
importLinkfrom'fumadocs-core/link';
7
7
8
-
In the code snippet, you will find `txBuilder`, which is an instance of `MeshTxBuilder`, a powerful low-level APIs that allows you to build transactions. Learn how to initialize **MeshTxBuilder**.
8
+
In the code snippet, you will find `txBuilder`, which is an instance of `MeshTxBuilder`, with powerful low-level APIs that allow you to build transactions. Here's how to initialize **MeshTxBuilder**.
9
9
10
10
```tsx
11
11
const txBuilder =newMeshTxBuilder({
@@ -21,7 +21,7 @@ In this page, we will cover how to initialize the `MeshTxBuilder` and the basic
21
21
22
22
## Initialize Tx Builder
23
23
24
-
To start building an customized transaction, you need to first initialize `MeshTxBuilder`:
24
+
To start building a customized transaction, you need to first initialize `MeshTxBuilder`:
@@ -48,7 +48,7 @@ The `MeshTxBuilder` instance has the following signature:
48
48
}
49
49
```
50
50
51
-
There are 6 optional fields to pass in to initialized the lower level APIs instance:
51
+
There are 6 optional fields to pass in when initializing a new instance:
52
52
53
53
-`serializer`: The default serializer is `CSLSerializer`. You can pass in your own serializer instance.
54
54
-`fetcher`: When you build the transaction without sufficient fields as required by the serialization library, we would index the blockchain to fill the information for you. Affected APIs are `txIn`, `txInCollateral`, `spendingTxInReference`.
@@ -61,15 +61,15 @@ There are 6 optional fields to pass in to initialized the lower level APIs insta
61
61
62
62
## Send Value
63
63
64
-
Sending value with `MeshTxBuilder`come with the `.txOut()` endpoint:
64
+
Sending value with `MeshTxBuilder`is done using the `.txOut()` endpoint:
65
65
66
66
```tsx
67
67
.txOut(address: string, amount: Asset[])
68
68
```
69
69
70
-
In order to send values (so as every transaction), we have to fund the transaction to do so. There are 2 ways to provide values in a transaction:
70
+
To send value in a transaction, you must first fund it. There are 2 ways:
Create a multi-signature transaction. In this demo, we will create a transaction with two signatures, where one signature is from the user wallet and the other is from a minting wallet.
165
+
Create a multi-signature transaction. In this demo, we will create a transaction with two signatures, where one signature is from the user's wallet and the other is from a minting wallet.
166
166
167
167
```tsx
168
168
const mintingWallet =newMeshWallet({
@@ -335,21 +335,21 @@ The second parameter of `selectUtxosFrom` is the strategy to be used for selecti
335
335
336
336
We may introduce more strategies in the future. Check the <Linkhref="https://docs.meshjs.dev/"> Mesh Docs</Link> for more details.
337
337
338
-
The `threshold` parameter is used to specify the minimum amount of lovelace to be selected. You may specify a larger amount to if the transactions requires it.
338
+
The `threshold` parameter is used to specify the minimum amount of lovelace to be selected. You may specify a larger amount too if the transactions requires it.
339
339
340
340
The last parameter is `includeTxFees` which is a boolean value to include transaction fees in the selection.
341
341
342
342
343
-
## Set Metadata - Taransaction message
343
+
## Set Metadata - Transaction message
344
344
345
-
Add messages / comments / memos as transaction metadata. This is useful for attaching additional information to a transaction. This is an example of setting metadata with transaction message.
345
+
Add messages / comments / memos as transaction metadata. This is useful for attaching additional information to a transaction. This is an example of setting a metadata with transaction message.
346
346
347
347
```tsx
348
348
txBuilder
349
349
.metadataValue(label, metadata)
350
350
```
351
351
352
-
The specification for the individual strings follow the general design specification for JSON metadata, which is already implemented and in operation on the cardano blockchain. The used metadatum label is `674`: this number was chosen because it is the T9 encoding of the string `msg`. The message content has the key `msg`: and consists of an array of individual message-strings. The number of theses message-strings must be at least one for a single message, more for multiple messages/lines. Each of theses individual message-strings array entries must be at most 64 bytes when UTF-8 encoded.
352
+
The specification for individual strings follows the general JSON metadata design, which is currently used on the Cardano blockchain. The used metadatum label is `674`: this number was chosen because it is the T9 encoding of the string `msg`. The message content has the key `msg`: and consists of an array of individual message-strings. The number of theses message-strings must be at least one for a single message, more for multiple messages/lines. Each of theses individual message-strings array entries must be at most 64 bytes when UTF-8 encoded.
353
353
354
354
<Card>
355
355
### Transaction message [!toc]
@@ -415,14 +415,14 @@ let dateTimeAdd5Min = new Date(nowDateTime.getTime() + minutes*60000);
Next, we set the TTL with `invalidHereafter` and providing the `slot`, this means that if the transaction is submitted after after `slot` will not be valid.
418
+
Next, we set the TTL by calling `invalidHereafter(slot)`. A transaction submitted after this value is invalid:
419
419
420
420
```tsx
421
421
txBuilder
422
422
.invalidHereafter(Number(slot));
423
423
```
424
424
425
-
Likewise, we can set a "validity start interval" for the transaction, where it is the time the transaction will be valid. We can define the start time with `invalidBefore` and providing the `slot`:
425
+
Likewise, we can call `invalidBefore(slot)` to specify the validity start interval. A transaction submitted before this value is invalid:
426
426
427
427
```tsx
428
428
txBuilder
@@ -434,7 +434,7 @@ txBuilder
434
434
435
435
Sets the network to use, this is mainly to know the cost models to be used to calculate script integrity hash. You can set the network for the transaction with `setNetwork`.
436
436
437
-
`
437
+
```tsx
438
438
txBuilder.setNetwork(network: Network)
439
439
```
440
440
@@ -447,7 +447,7 @@ The network parameter is a string that can be one of the following:
447
447
448
448
## Set Fee
449
449
450
-
Set the fee for the transaction.
450
+
Set the fee for the transaction in lovelace.
451
451
452
452
```tsx
453
453
.setFee(fee: string)
@@ -476,4 +476,4 @@ const txBuilder = new MeshTxBuilder({
0 commit comments