From f1d86d35a279fdde094ed4b4276b29ddfdb1f87e Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:14:15 +0200 Subject: [PATCH 1/9] Update README.md --- README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index baa438d5..f43681cf 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,26 @@ yarn install yarn start ``` -# 🏗 Web3 Components +# 🧭 Table of contents + +- [`ethereum-boilerplate`](#ethereum-boilerplate) +- [🚀 Quick Start](#-quick-start) +- [🧭 Table of contents](#-table-of-contents) +- [🏗 Ethereum Components](#-ethereum-components) + - [``](#addressinput-) + - [``](#chains-) + - [``](#coinprice-) + - [``](#erc20balance-) + - [``](#erc20transfers-) + - [``](#dex-) + - [``](#wallet-) + - [``](#blockie-) + - [``](#nativebalance-) + - [``](#contract-) +- [🧰 Ethereum Hooks](#-ethereum-hooks) + + +# 🏗 Ethereum Components 🛠 The ready for use react-components are located in `src/components`. They are designed to be used anywhere in your dApp. @@ -167,3 +186,19 @@ const [address, setAddress] = useState(); ### `` + +# 🧰 Ethereum Hooks + +### `useChain()` + +### `useERC20Balance()` + +### `useERC20Transfers()` + +### `useInchDex()` + +### `useNativeBalance()` + +### `useNFTBalance()` + +### `useTokenPrice()` From e123b4f1900f8aa3ce43ac93e1d9132659a2538a Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 01:18:14 +0200 Subject: [PATCH 2/9] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index f43681cf..81d534b3 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,13 @@ yarn start - [``](#nativebalance-) - [``](#contract-) - [🧰 Ethereum Hooks](#-ethereum-hooks) + - [`useChain()`](#usechain) + - [`useERC20Balance()`](#useerc20balance) + - [`useERC20Transfers()`](#useerc20transfers) + - [`useInchDex()`](#useinchdex) + - [`useNativeBalance()`](#usenativebalance) + - [`useNFTBalance()`](#usenftbalance) + - [`useTokenPrice()`](#usetokenprice) # 🏗 Ethereum Components From f3d17f481e92ccb53aaf2710bf9c6d43756c218f Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 02:04:26 +0200 Subject: [PATCH 3/9] Update README.md --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 81d534b3..808088bd 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,16 @@ yarn start - [``](#nativebalance-) - [``](#contract-) - [🧰 Ethereum Hooks](#-ethereum-hooks) - - [`useChain()`](#usechain) - [`useERC20Balance()`](#useerc20balance) - [`useERC20Transfers()`](#useerc20transfers) - - [`useInchDex()`](#useinchdex) - [`useNativeBalance()`](#usenativebalance) + - [`useNativeTransactions()`](#usenativetransactions) - [`useNFTBalance()`](#usenftbalance) + - [`useNFTTransfers()`](#usenfttransfers) + - [`useNFTTransfers()`](#usenfttransfers) + - [`useChain()`](#usechain) - [`useTokenPrice()`](#usetokenprice) + - [`useInchDex()`](#useinchdex) # 🏗 Ethereum Components @@ -196,16 +199,20 @@ const [address, setAddress] = useState(); # 🧰 Ethereum Hooks -### `useChain()` - ### `useERC20Balance()` ### `useERC20Transfers()` -### `useInchDex()` - ### `useNativeBalance()` +### `useNativeTransactions()` + ### `useNFTBalance()` +### `useNFTTransfers()` + +### `useChain()` + +### `useInchDex()` + ### `useTokenPrice()` From f501b7a2965d24b0e26c891640ba9bb8f107d856 Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:06:18 +0200 Subject: [PATCH 4/9] Update README.md --- README.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 808088bd..f3a4d53d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,6 @@ yarn start - [`useTokenPrice()`](#usetokenprice) - [`useInchDex()`](#useinchdex) - # 🏗 Ethereum Components 🛠 The ready for use react-components are located in `src/components`. They are designed to be used anywhere in your dApp. @@ -194,7 +193,6 @@ const [address, setAddress] = useState(); ### `` - ### `` # 🧰 Ethereum Hooks @@ -207,6 +205,20 @@ const [address, setAddress] = useState(); ### `useNativeTransactions()` +Gets the transactions from the current user or address. Returns an object with the number of transactions and the array of native transactions + +**Options**: +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth. +- `address` (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead. +- `from_date` (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used. +- `to_date` (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used. +- `from_block` (optional): The minimum block number from where to get the transactions Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used. +- `to_block` (optional): The maximum block number from where to get the transactions. Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used. +- `offset` (optional): Offset. +- `limit` (optional): Limit. + +**Returns**: (Array) : native transactions + ### `useNFTBalance()` ### `useNFTTransfers()` From 0b56860be9457966e2e2277fa399cf4b1600b513 Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:07:27 +0200 Subject: [PATCH 5/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f3a4d53d..6dce817d 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ Gets the transactions from the current user or address. Returns an object with t - `offset` (optional): Offset. - `limit` (optional): Limit. -**Returns**: (Array) : native transactions +**Returns** (Array) : native transactions ### `useNFTBalance()` From 36e7f3bfffdfda4a6ff57f3b2fa01f471c0e55b8 Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 03:59:12 +0200 Subject: [PATCH 6/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6dce817d..236221cd 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ yarn start - [`useNFTBalance()`](#usenftbalance) - [`useNFTTransfers()`](#usenfttransfers) - [`useNFTTransfers()`](#usenfttransfers) + - [`useIPFS()`](#useipfs) - [`useChain()`](#usechain) - [`useTokenPrice()`](#usetokenprice) - [`useInchDex()`](#useinchdex) @@ -228,3 +229,5 @@ Gets the transactions from the current user or address. Returns an object with t ### `useInchDex()` ### `useTokenPrice()` + +### `useIPFS()` From 012819ecd09db20cc0aaabf9d30df2b2397bb03b Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 11:54:04 +0200 Subject: [PATCH 7/9] Update README.md --- README.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/README.md b/README.md index 236221cd..2387ed1d 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ yarn start - [``](#nativebalance-) - [``](#contract-) - [🧰 Ethereum Hooks](#-ethereum-hooks) + - [`useAPIContract()`](#useapicontract) + - [`useWeb3Contract()`](#useweb3contract) - [`useERC20Balance()`](#useerc20balance) - [`useERC20Transfers()`](#useerc20transfers) - [`useNativeBalance()`](#usenativebalance) @@ -198,6 +200,74 @@ const [address, setAddress] = useState(); # 🧰 Ethereum Hooks +### `useAPIContract()` + +📋 Runs a given function of a contract abi and returns readonly data. Uses Moralis Web3API (does not require an active web3 provider). + +**Options**: +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth. +- `functionName` (required): The function name +- `address` (required): A smart contract address +- `abi` (required): contract or function ABI(should be provided as an array) + +**Example**: +```jsx +const ShowUniswapTotalSupplyLP = () => { + const { runContractFunction, contractResponse, error, isLoading } = useAPIContract({ + abi: usdcEthPoolAbi, + address: usdcEthPoolAddress, + functionName: "totalSupply", + }); + + return (
+ {error && } + + {data &&
+      {JSON.stringify(contractResponse),
+        null,
+        2,
+      )}
+    
} +
) +} +``` + +### `useWeb3Contract()` + +📋 Runs on-chain functions. Requires active Web3 Provider. + +**Options**: +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth. +- `functionName` (required): The function name +- `contractAddress` (required): A smart contract address +- `abi` (required): contract or function ABI(should be provided as an array) +- `params` (optional): Parameters needed for your specific function + +**Example**: +```jsx +const ShowUniswapObserveValues = () => { + const { runContractFunction, contractResponse, error, isLoading } = useWeb3Contract({ + abi: usdcEthPoolAbi, + contractAddress: usdcEthPoolAddress, + functionName: "observe", + params: { + secondsAgos: [0, 10], + }, + }); + + return (
+ {error && } + + {data &&
+      {JSON.stringify(contractResponse),
+        null,
+        2,
+      )}
+    
} +
) +} +``` + ### `useERC20Balance()` ### `useERC20Transfers()` From bed9ced4b1e90d41e99f7892f01a0413fdf8ab87 Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 13:24:42 +0200 Subject: [PATCH 8/9] Update README.md --- README.md | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2387ed1d..fb1e8fca 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ const ShowUniswapTotalSupplyLP = () => { **Example**: ```jsx const ShowUniswapObserveValues = () => { - const { runContractFunction, contractResponse, error, isLoading } = useWeb3Contract({ + const { runContractFunction, contractResponse, error, isRunning, isLoading } = useWeb3Contract({ abi: usdcEthPoolAbi, contractAddress: usdcEthPoolAddress, functionName: "observe", @@ -270,16 +270,49 @@ const ShowUniswapObserveValues = () => { ### `useERC20Balance()` +💰 Gets all token balances of a current user or specified address. + +**Options**: +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain. +- `address` (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead. +- `to_block` (optional): The block number on which the balances should be checked + +**Returns** (Object) : number of tokens and the array of token objects + +```jsx +const { fetchERC20Balance, assets } = useERC20Balance({ chain : "eth" }); +``` + ### `useERC20Transfers()` ### `useNativeBalance()` +💰 Gets native balance for a specific address. The `nativeName` from `useNativeBalance()` shows name of chain(Example: "BNB", "ETH", ...) + +**Options**: +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain. +- `address` (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead. +- `to_block` (optional): The block number on which the balances should be checked + +**Returns** (Object) : { inWei: balance in Wei , formatted: balance in Eth style } + +**Example**: +```jsx + +function NativeBalance() { + const { getBalance, balance, nativeName, error, isLoading } = useNativeBalance({ chain : "eth" }); + return ( +
{`${balance.formatted} ${nativeName}`}
+ ); +} +``` + ### `useNativeTransactions()` Gets the transactions from the current user or address. Returns an object with the number of transactions and the array of native transactions **Options**: -- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value Eth. +- `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain. - `address` (optional): A user address (i.e. 0x1a2b3x...). If specified, the user attached to the query is ignored and the address will be used instead. - `from_date` (optional): The date from where to get the transactions (any format that is accepted by momentjs). Provide the param 'from_block' or 'from_date' If 'from_date' and 'from_block' are provided, 'from_block' will be used. - `to_date` (optional): Get the transactions to this date (any format that is accepted by momentjs). Provide the param 'to_block' or 'to_date' If 'to_date' and 'to_block' are provided, 'to_block' will be used. From 6af5631d1e1ba77da6b06ec9c6243b437ee3019d Mon Sep 17 00:00:00 2001 From: Dmitry Kapeliushnyi <78314301+Y0moo@users.noreply.github.com> Date: Sat, 30 Oct 2021 13:26:25 +0200 Subject: [PATCH 9/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb1e8fca..9c10e29a 100644 --- a/README.md +++ b/README.md @@ -287,7 +287,7 @@ const { fetchERC20Balance, assets } = useERC20Balance({ chain : "eth" }); ### `useNativeBalance()` -💰 Gets native balance for a specific address. The `nativeName` from `useNativeBalance()` shows name of chain(Example: "BNB", "ETH", ...) +💰 Gets native balance for a current user or specified address. The `nativeName` from `useNativeBalance()` shows name of chain(Example: "BNB", "ETH", ...) **Options**: - `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain. @@ -309,7 +309,7 @@ function NativeBalance() { ### `useNativeTransactions()` -Gets the transactions from the current user or address. Returns an object with the number of transactions and the array of native transactions +Gets the transactions from the current user or specified address. Returns an object with the number of transactions and the array of native transactions **Options**: - `chain` (optional): The blockchain to get data from. Valid values are listed on the intro page in the Transactions and Balances section. Default value: current chain.