1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-06-15 17:03:21 +02:00
react/src/utils/web3.ts
2020-10-05 10:09:42 +03:00

16 lines
436 B
TypeScript

import Web3 from 'web3'
import { Account } from '@oceanprotocol/lib'
import { Balance } from 'providers'
export async function getAccountId(web3: Web3): Promise<string> {
const accounts = await web3.eth.getAccounts()
return accounts[0]
}
export async function getBalance(account: Account): Promise<Balance> {
const eth = await account.getEtherBalance()
const ocean = await account.getOceanBalance()
return { eth, ocean }
}