1.0.2 • Published 1 year ago
simple-wax v1.0.2
:rocket: How use
Instalation:
npm install simple-wax@latest
#or
yarn add simple-wax@latest
Answer the questions (When choosing the tool, use the arrows keys to navigate, the spacebar to select and enter to finish)
Start integration adding the AuthProvider component to your application:
import { AuthProvider } from "simple-wax";
import App from "./App";
const endpoint = "http://wax-testnet.cryptolions.io/";
const chainId =
"f16b1833c747c43682f4386fca9cbb327929334a762755ebec17f6f23c9b8a12";
const appName = "simple-wax";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<AuthProvider endpoint={endpoint} chainId={chainId} appName={appName}>
<App />
</AuthProvider>
</React.StrictMode>
);
Now you can use the useAuth hook to get the user data:
import { useAuth } from "simple-wax";
const App = () => {
const { activeUserData, handleAnchorSignIn, handleWaxSignIn, handleLogout } = useAuth();
return (
<div>
<h1>Simple Wax</h1>
<button onClick={handleWaxSignIn}>WAX Login</button>
<button onClick={handleAnchorSignIn}>Anchor Login</button>
<button onClick={handleLogout}>Logout</button>
<p>{JSON.stringify(activeUserData)}</p>
</div>
);
};
For dispatching actions, you can use the ActionSevice method:
import { useAuth } from "simple-wax";
const App = () => {
const { activeUserData, ActionService } = useAuth();
const handleBuy = () => {
const authorization = [
{
actor: activeUserData?.accountName,
permission: activeUserData?.requestPermission,
},
];
const action = {
//... add action account and name
authorization,
//... add action data
}
ActionService({
type: activeUserData?.wallet,
actions: [action],
});
}
return (
<div>
<h1>Simple Wax</h1>
<button onClick={handleBuy}>Buy</button>
</div>
);
};
:pencil: Contributing
Your contribution to the simple-wax
is essential for the evolution of the project, you can do it as follows:
- Open an issue to clear doubts, report bugs or give ideas
- Open a pull request to give ideas for code improvement, implementation of new features and bug fixes
These are just some of the ways you can contribute to the project read the CONTRIBUTING for more information
:adult: Authors
✨ Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
:page_facing_up: License
simple-wax is a open source project licensed as MIT.