<p>Assuming you are using React in the front-end,you can use the serialization library created by emurgo.After installing their library you first connect to a wallet like this. I will be connecting to a yoroi wallet , for any other wallet you can just swap out the name and it works same way.</p>
<pre><code>import {Value} from &quot;@emurgo/cardano-serialization-lib-asmjs&quot;
let Buffer = require('buffer/').Buffer
</code></pre>
<pre><code>const [balance,setBalance] = useState()
let API = &quot;&quot;
const connectToWallet = async () =&gt;{
        try {
            API = await window.cardano.yoroi.enable();
        } catch(err) {
            console.log(err);
        }
}
</code></pre>
<p>After you enable it , it will return a api key. You can then use the API key to get the balance of wallet.</p>
<pre><code>    getBalance = async () =&gt; {
        try {
            const balanceCBORHex = await API.getBalance();
            const balance = Value.from_bytes(Buffer.from(balanceCBORHex, &quot;hex&quot;)).coin().to_str();
            setBalance(balance)

        } catch (err) {
            console.log(err)
        }
 
    }
</code></pre>

CC BY-SA 4.0
2022-06-01T12:30:33.900Z
Thanks @hang9921 that would be useful in the future. At this moment I'm programming in Haskell in the server. I need to access a server wallet like daedalus or the  cardano-wallet in https://github.com/input-output-hk/plutus-apps
agocorona
CC BY-SA 4.0
2022-07-03T16:03:22.080Z
Have you check out Cardano-transaction-library. https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/doc/getting-started.md
szhang9921
CC BY-SA 4.0
2022-05-31T14:51:41.013Z
2022-05-31T14:56:57.960Z
2022-05-31T14:56:57.960Z
szhang9921
<p>I need to know the amount of Ada remaining in an account in a off-chain Haskell plutus program. Should I use the wallet web interface of the kind:</p>
<p>http://localhost:8090/v2/wallets/$WALLET_ID</p>
<p>or there is some direct Plutus library call or haskell serialization library for that?</p>

<plutus><wallet>
Plutus: how to obtain wallet details. Do I have to use the wallet web interface or there is some direct library call?
# Plutus: how to obtain wallet details. Do I have to use the wallet web interface or there is some direct library call?

(Asked by: username_0 on 2022-05-30)

I need to know the amount of Ada remaining in an account in a off-chain Haskell plutus program. Should I use the wallet web interface of the kind:

http://localhost:8090/v2/wallets/$WALLET\_ID

or there is some direct Plutus library call or haskell serialization library for that?

**Tags:** plutus, wallet

---

## 1 answers

### Answer by username_1 on 2022-05-31. Score: 1

Assuming you are using React in the front-end,you can use the serialization library created by emurgo.After installing their library you first connect to a wallet like this. I will be connecting to a yoroi wallet , for any other wallet you can just swap out the name and it works same way.
import {Value} from "@emurgo/cardano-serialization-lib-asmjs"
let Buffer = require('buffer/').Buffer

const [balance,setBalance] = useState()
let API = ""
const connectToWallet = async () =>{
        try {
            API = await window.cardano.yoroi.enable();
        } catch(err) {
            console.log(err);
        }
}

After you enable it , it will return a api key. You can then use the API key to get the balance of wallet.
    getBalance = async () => {
        try {
            const balanceCBORHex = await API.getBalance();
            const balance = Value.from_bytes(Buffer.from(balanceCBORHex, "hex")).coin().to_str();
            setBalance(balance)

        } catch (err) {
            console.log(err)
        }
 
    }

> **Comments:**
> **username_0**: Thanks @hang9921 that would be useful in the future. At this moment I'm programming in Haskell in the server. I need to access a server wallet like daedalus or the  cardano-wallet in https://github.com/input-output-hk/plutus-apps  
> **username_1**: Have you check out Cardano-transaction-library. https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/doc/getting-started.md  

---

