<p>You cannot. If you want to use the PAB, you need to send the necessary information from the wallet (utxos, pkh, whatever your script needs) in the frontend and then yield the unbalancedTx back to the frontend, and then balance it there. Alternatively, you could implement your own balancing function in Haskell and do it there. Aiken, Lucid, and Martify Mesh are all examples of front-end transaction building libraries that support transaction balancing. In-fact, you can use any one of those entirely without using the PAB at all.</p>

CC BY-SA 4.0
2022-11-10T18:57:49.023Z
2022-11-10T18:57:49.023Z
Philip DiSarro
<p>According to the Plutus team, the standard way of generating signed transactions containing smart contracts is to have the off-chain code generate a so called unbalanced transaction that is then, in a second step, balanced and signed by the user's wallet. The newest <a href="https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab-executables/demo/pab-nami" rel="noreferrer">Nami-demo</a> of the PAB repository follows this spirit and makes the observation that this <code>balanceTx</code> method is currently missing in the Nami API. The demo implements a work around method for balancing and comments that this method could be deleted once Nami implements a proper API analog (<a href="https://github.com/input-output-hk/plutus-apps/blob/main/plutus-pab-executables/demo/pab-nami/client/src/Cardano/Wallet/Nami.js#L71" rel="noreferrer">see line 71 here</a>).</p>
<p>I asked on the Nami repository if we could expect a method for balancing transactions soon: <a href="https://github.com/Berry-Pool/nami-wallet/issues/183" rel="noreferrer">see-here</a>.
The answer was that such a method would be difficult to implement as smart contract execution costs —which are affected by the balancing— need to be factored into the fees and that this calculation needs the availability of Plutus Core (which I guess is not easily achievable for web extensions).</p>
<p>The only way left for implementing smart contracts is to hand over a fully built transaction to the wallet. When using the PAB, the Contract instance would need to build it using the wallet address (and optionally a pre-defined UTxO for the collateral) of the user. I haven't seen any code showing how to achieve this in the GitHub repository. How can this be done ?</p>

<plutus><transaction><pab>
How can I get a fully built transaction from the PAB
# How can I get a fully built transaction from the PAB

(Asked by: username_0 on 2022-01-08)

According to the Plutus team, the standard way of generating signed transactions containing smart contracts is to have the off-chain code generate a so called unbalanced transaction that is then, in a second step, balanced and signed by the user's wallet. The newest [Nami-demo](https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab-executables/demo/pab-nami) of the PAB repository follows this spirit and makes the observation that this `balanceTx` method is currently missing in the Nami API. The demo implements a work around method for balancing and comments that this method could be deleted once Nami implements a proper API analog ([see line 71 here](https://github.com/input-output-hk/plutus-apps/blob/main/plutus-pab-executables/demo/pab-nami/client/src/Cardano/Wallet/Nami.js#L71)).

I asked on the Nami repository if we could expect a method for balancing transactions soon: [see-here](https://github.com/Berry-Pool/nami-wallet/issues/183).
The answer was that such a method would be difficult to implement as smart contract execution costs —which are affected by the balancing— need to be factored into the fees and that this calculation needs the availability of Plutus Core (which I guess is not easily achievable for web extensions).

The only way left for implementing smart contracts is to hand over a fully built transaction to the wallet. When using the PAB, the Contract instance would need to build it using the wallet address (and optionally a pre-defined UTxO for the collateral) of the user. I haven't seen any code showing how to achieve this in the GitHub repository. How can this be done ?

**Tags:** plutus, transaction, pab

---

## 1 answers

### Answer by username_1 on 2022-11-10. Score: 1

You cannot. If you want to use the PAB, you need to send the necessary information from the wallet (utxos, pkh, whatever your script needs) in the frontend and then yield the unbalancedTx back to the frontend, and then balance it there. Alternatively, you could implement your own balancing function in Haskell and do it there. Aiken, Lucid, and Martify Mesh are all examples of front-end transaction building libraries that support transaction balancing. In-fact, you can use any one of those entirely without using the PAB at all.


---

