hippospace / aptos-wallet-adapter

Other
93 stars 96 forks source link

How get balance wallet #84

Closed Meerch closed 2 years ago

Meerch commented 2 years ago

Does anyone know how to get a wallet balance in the amount of APT ?

Meerch commented 2 years ago

I find resolve

const aptosClient = new AptosClient(NODE_URL);
        const coinClient = new CoinClient(aptosClient);
        // @ts-ignore
       // account.address === MaybeHexString, and checkBalance need {address: HexString}
        const result = await coinClient.checkBalance({address: () => account.address}) 
        if (result) {
            // result === 387242100n, and really balance 3.87242100
            setBalance(parseInt(String(result)) / 100000000)
        }