Skip to content

Commit

Permalink
deploy: c69cb81
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3e committed Dec 14, 2023
1 parent f8b31b3 commit db4386f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 32 deletions.
9 changes: 2 additions & 7 deletions master/cookbook/transfer-all-assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,8 @@ <h1 id="transfer-all-assets"><a class="header" href="#transfer-all-assets">Trans
}
</code></pre>
<p>All that is left is to build the transaction via <code>ScriptTransactionBuilder</code>, have <code>wallet_1</code> sign it, and we can send it. We confirm this by checking the number of balances present in the receiving wallet and their amount:</p>
<pre><code class="language-rust ignore"> let network_info = provider.network_info().await?;
let mut tb = ScriptTransactionBuilder::prepare_transfer(
inputs,
outputs,
TxPolicies::default(),
network_info,
);
<pre><code class="language-rust ignore"> let mut tb =
ScriptTransactionBuilder::prepare_transfer(inputs, outputs, TxPolicies::default());
wallet_1.sign_transaction(&amp;mut tb);
let tx = tb.build(&amp;provider).await?;

Expand Down
5 changes: 2 additions & 3 deletions master/custom-transactions/transaction-builders.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h1 class="menu-title">The Fuel Rust SDK</h1>
<main>
<h1 id="transaction-builders"><a class="header" href="#transaction-builders">Transaction Builders</a></h1>
<p>The Rust SDK simplifies the creation of <strong>Create</strong> and <strong>Script</strong> transactions through two handy builder structs <code>CreateTransactionBuilder</code>, <code>ScriptTransactionBuilder</code>, and the <code>TransactionBuilder</code> trait.</p>
<p>Calling <code>build()</code> on a builder will result in the corresponding <code>CreateTransaction</code> or <code>ScriptTransaction</code> that can be submitted to the network.</p>
<p>Calling <code>build(&amp;provider)</code> on a builder will result in the corresponding <code>CreateTransaction</code> or <code>ScriptTransaction</code> that can be submitted to the network.</p>
<h2 id="role-of-the-transaction-builders"><a class="header" href="#role-of-the-transaction-builders">Role of the transaction builders</a></h2>
<blockquote>
<p><strong>Note</strong> This section contains additional information about the inner workings of the builders. If you are just interested in how to use them, you can skip to the next section.</p>
Expand All @@ -160,8 +160,7 @@ <h2 id="creating-a-custom-transaction"><a class="header" href="#creating-a-custo
</code></pre>
<p>Our goal is to create a transaction that will use our hot wallet to transfer the <strong>ask_amount</strong> to the <strong>receiver</strong> and then send the unlocked predicate assets to a second wallet that acts as our cold storage.</p>
<p>Let's start by instantiating a builder. Since we don't plan to deploy a contract, the <code>ScriptTransactionBuilder</code> is the appropriate choice:</p>
<pre><code class="language-rust ignore"> let network_info = provider.network_info().await?;
let tb = ScriptTransactionBuilder::new(network_info);
<pre><code class="language-rust ignore"> let tb = ScriptTransactionBuilder::default();
</code></pre>
<p>Next, we need to define transaction inputs of the base asset that sum up to <strong>ask_amount</strong>. We also need transaction outputs that will assign those assets to the predicate address and thereby unlock it. The methods <code>get_asset_inputs_for_amount</code> and <code>get_asset_outputs_for_amount</code> can help with that. We need to specify the asset ID, the target amount, and the target address:</p>
<pre><code class="language-rust ignore"> let base_inputs = hot_wallet
Expand Down
19 changes: 4 additions & 15 deletions master/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,6 @@ <h2 id="signing-a-transaction"><a class="header" href="#signing-a-transaction">S
)?;
let wallet = WalletUnlocked::new_from_private_key(secret, None);

let network_info = NetworkInfo {
consensus_parameters: Default::default(),
min_gas_price: 0,
};
// Set up a transaction
let mut tb = {
let input_coin = Input::ResourceSigned {
Expand All @@ -929,7 +925,6 @@ <h2 id="signing-a-transaction"><a class="header" href="#signing-a-transaction">S
vec![input_coin],
vec![output_coin],
Default::default(),
network_info,
)
};

Expand Down Expand Up @@ -2487,7 +2482,7 @@ <h2 id="configurable-constants-2"><a class="header" href="#configurable-constant
<p>Until now, we have used helpers to create transactions, send them with a provider, and parse the results. However, sometimes we must make custom transactions with specific inputs, outputs, witnesses, etc. In the next chapter, we will show how to use the Rust SDKs transaction builders to accomplish this.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="transaction-builders"><a class="header" href="#transaction-builders">Transaction Builders</a></h1>
<p>The Rust SDK simplifies the creation of <strong>Create</strong> and <strong>Script</strong> transactions through two handy builder structs <code>CreateTransactionBuilder</code>, <code>ScriptTransactionBuilder</code>, and the <code>TransactionBuilder</code> trait.</p>
<p>Calling <code>build()</code> on a builder will result in the corresponding <code>CreateTransaction</code> or <code>ScriptTransaction</code> that can be submitted to the network.</p>
<p>Calling <code>build(&amp;provider)</code> on a builder will result in the corresponding <code>CreateTransaction</code> or <code>ScriptTransaction</code> that can be submitted to the network.</p>
<h2 id="role-of-the-transaction-builders"><a class="header" href="#role-of-the-transaction-builders">Role of the transaction builders</a></h2>
<blockquote>
<p><strong>Note</strong> This section contains additional information about the inner workings of the builders. If you are just interested in how to use them, you can skip to the next section.</p>
Expand All @@ -2508,8 +2503,7 @@ <h2 id="creating-a-custom-transaction"><a class="header" href="#creating-a-custo
</code></pre>
<p>Our goal is to create a transaction that will use our hot wallet to transfer the <strong>ask_amount</strong> to the <strong>receiver</strong> and then send the unlocked predicate assets to a second wallet that acts as our cold storage.</p>
<p>Let's start by instantiating a builder. Since we don't plan to deploy a contract, the <code>ScriptTransactionBuilder</code> is the appropriate choice:</p>
<pre><code class="language-rust ignore"> let network_info = provider.network_info().await?;
let tb = ScriptTransactionBuilder::new(network_info);
<pre><code class="language-rust ignore"> let tb = ScriptTransactionBuilder::default();
</code></pre>
<p>Next, we need to define transaction inputs of the base asset that sum up to <strong>ask_amount</strong>. We also need transaction outputs that will assign those assets to the predicate address and thereby unlock it. The methods <code>get_asset_inputs_for_amount</code> and <code>get_asset_outputs_for_amount</code> can help with that. We need to specify the asset ID, the target amount, and the target address:</p>
<pre><code class="language-rust ignore"> let base_inputs = hot_wallet
Expand Down Expand Up @@ -3635,13 +3629,8 @@ <h2 id="loadscript"><a class="header" href="#loadscript"><code>LoadScript</code>
}
</code></pre>
<p>All that is left is to build the transaction via <code>ScriptTransactionBuilder</code>, have <code>wallet_1</code> sign it, and we can send it. We confirm this by checking the number of balances present in the receiving wallet and their amount:</p>
<pre><code class="language-rust ignore"> let network_info = provider.network_info().await?;
let mut tb = ScriptTransactionBuilder::prepare_transfer(
inputs,
outputs,
TxPolicies::default(),
network_info,
);
<pre><code class="language-rust ignore"> let mut tb =
ScriptTransactionBuilder::prepare_transfer(inputs, outputs, TxPolicies::default());
wallet_1.sign_transaction(&amp;mut tb);
let tx = tb.build(&amp;provider).await?;

Expand Down
2 changes: 1 addition & 1 deletion master/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion master/searchindex.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions master/wallets/signing.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ <h2 id="signing-a-transaction"><a class="header" href="#signing-a-transaction">S
)?;
let wallet = WalletUnlocked::new_from_private_key(secret, None);

let network_info = NetworkInfo {
consensus_parameters: Default::default(),
min_gas_price: 0,
};
// Set up a transaction
let mut tb = {
let input_coin = Input::ResourceSigned {
Expand All @@ -204,7 +200,6 @@ <h2 id="signing-a-transaction"><a class="header" href="#signing-a-transaction">S
vec![input_coin],
vec![output_coin],
Default::default(),
network_info,
)
};

Expand Down

0 comments on commit db4386f

Please sign in to comment.