Skip to content

Commit

Permalink
feat: update account balance method to account.balanceOf with support…
Browse files Browse the repository at this point in the history
… for multiple addresses
  • Loading branch information
Ben-Rey committed Dec 20, 2024
1 parent aae178c commit 7145e85
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions standard/dapps-communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,29 +448,39 @@ massaWallets[0]

---

#### **`account.balance`**
#### **`account.balanceOf`**

- **Description**: Retrieves the balance of provided addresses, including both final and candidate balances.
- **Parameters**:

```typescript
type AccountBalanceParams = {
addresses: string[]; // The addresses to fetch balances for.
};

- **Description**: Retrieves the account's balance, including both final and candidate balances.
- **Parameters**: None
- **Returns**:

```typescript
type AccountBalance = {
address: string; // The address of the account.
final: string; // The final balance of the account.
candidate: string; // The candidate balance of the account.
};
Promise<AccountBalance>;
Promise<AccountBalance[]>;
```

#### Example:

```javascript
massaWallets[0]
.request({ method: "account.balance", params: {} })
.then((balance) => {
console.log("Final balance:", balance.final);
console.log("Candidate balance:", balance.candidate);
.request({ method: "account.balanceOf", params: {} })
.then((result) => {
for (const balance of result) {
console.log("Address:", balance.address);
console.log("Final balance:", balance.final);
console.log("Candidate balance:", balance.candidate);
}
})
.catch((error) => {
console.error("Error fetching balance:", error);
Expand Down

0 comments on commit 7145e85

Please sign in to comment.