An open API service indexing awesome lists of open source software.

https://github.com/cawfree/react-pretty-ethereum

⚛️ Ξ Render Web3 data models in a user-friendly way.
https://github.com/cawfree/react-pretty-ethereum

ethereum react react-native web3

Last synced: 2 months ago
JSON representation

⚛️ Ξ Render Web3 data models in a user-friendly way.

Awesome Lists containing this project

README

          

# react-pretty-ethereum
Tools to render Web3 data models in a user-friendly way, because [**Ethereum**](https://ethereum.org) is complicated enough for outsiders.

The project works in two simple ways:
- Firstly, you register mechanisms by which low-level information can be converted into something more useful to an end user.
- For instance, you could override an ethereum address to resolve to a user's profile name, if it was known.
- Secondly, you declare dedicated [**render props**](https://reactjs.org/docs/render-props.html) capable of handling the processed data.

Supports both [**React**](https://reactjs.org) and [**React Native**](https://reactnative.dev).

## 🚀 Getting Started

Using [**Yarn**](https://yarnpkg.com):

```bash
yarn add react-pretty-ethereum
```

## ✍️ Usage

Use the [` (

), []);

const renderCurrency = useCallback(({ value, currencyFormat, style }) => (



), []);

/* https://docs.sendwyre.com/docs/live-exchange-rates 10/12/20 */
const conversionRates = {
ETHGBP: 0.0035,
ETHUSD: 0.0027,
};

// TODO: test we can replace this
const resolveAddress = useCallback(({ value }) => {
if (value === Bob) {
return "Bob";
} else if (value === Alice) {
return "Alice";
}
return value;
}, []);

const resolveCurrency = useCallback(({ value }) => {
const { ETHGBP, ETHUSD } = conversionRates;
const valueInWei = BigNumber(value);
const valueInEth = BigNumber(valueInWei).dividedBy(ethers.constants.WeiPerEther.toString());
const USD = valueInEth.dividedBy(BigNumber(ETHUSD));
const GBP = valueInEth.dividedBy(BigNumber(ETHGBP));
return { GBP, USD };
}, [conversionRates]);

return (





{"🔥 "}






{" 🔥"}





);
}
```

This yields the following result:


react-pretty-web3

## ✌️ License
[**MIT**](./LICENSE)