Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-csouza committed Jun 5, 2023
1 parent a7fed8b commit 039a26b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The .env is not in .gitignore

POLYGON_ALCHEMY_URL=

MUMBAI_ALCHEMY_URL=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
# .env*.local

# vercel
.vercel
Expand Down
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
###Web3Context Hook
# Web3Context Hook

The useWeb3 hook is a custom hook that provides access to Ethereum-related data and functionality in your React applications. It is designed to simplify the interaction with the Ethereum network and Metamask wallet.

##Usage
## Usage

To use the useWeb3 hook, you need to wrap your application or component with the Web3Provider component. This component sets up the necessary context and makes the useWeb3 hook available for use.

javascript
Copy code
```javascript
import { Web3Provider } from './contexts/Web3Context';

function App() {
return (
<Web3Provider>
{/_ Your app components _/}
</Web3Provider>
);
return <Web3Provider>{/_ Your app components _/}</Web3Provider>;
}
```

Once the Web3Provider is set up, you can use the useWeb3 hook to access Ethereum-related data and functions in your components.

javascript
Copy code
```javascript

import { useWeb3 } from './contexts/Web3Context';

function MyComponent() {
Expand All @@ -30,6 +29,8 @@ return (
// Your component JSX
);
}
```

The useWeb3 hook provides the following properties and functions:

networkId: The ID of the connected Ethereum network.
Expand All @@ -43,34 +44,34 @@ By using these properties and functions, you can display the Ethereum-related da

Note: Make sure to handle error cases appropriately and provide a user-friendly experience in case of errors or connection issues.

##Example
## Example

Here's an example of how you can use the useWeb3 hook in your application:

javascript
Copy code
```javascript
import { useWeb3 } from './contexts/Web3Context';

function MyComponent() {
const { networkId, wallet, balance, status, connectWallet } = useWeb3();
const { networkId, wallet, balance, status, connectWallet } = useWeb3();

return (
<div>
<p>Network ID: {networkId}</p>
<p>Wallet: {wallet}</p>
<p>Balance: {balance}</p>
return (
<div>
<p>Network ID: {networkId}</p>
<p>Wallet: {wallet}</p>
<p>Balance: {balance}</p>

{status === 'NotConnected' && (
<button onClick={connectWallet}>Connect Wallet</button>
)}
{status === 'NotConnected' && <button onClick={connectWallet}>Connect Wallet</button>}

{/* Other component UI */}
</div>

);
);
}
```

In this example, we display the network ID, wallet address, and balance of the connected wallet. If the status is "NotConnected", we render a button to allow the user to connect their wallet.

Feel free to customize the UI and functionality based on your application's requirements.

##Conclusion
## Conclusion

The useWeb3 hook provided by the Web3Provider allows you to easily integrate Ethereum functionality into your React applications. By leveraging the Ethereum-related data and functions, you can build decentralized applications and interact with the Ethereum network with ease.

1 comment on commit 039a26b

@vercel
Copy link

@vercel vercel bot commented on 039a26b Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hookup – ./

hookup-wine.vercel.app
hookup-bilets-pro.vercel.app
hookup-git-main-bilets-pro.vercel.app

Please sign in to comment.