deserialize-evm-client-sdk
v4.4.0
Published
------ This is an SDK to ease the integration of deserialize functionalities with front-end
Downloads
11
Readme
DESERIALIZE-EVM-SDK
This is an SDK to ease the integration of deserialize functionalities with front-end
Installation
npm install deserialize-evm-client-sdkUsage
The package is a hook as such must be called on the client-side within a react component
- Use the "use client" directive at the top of your component
"use client"
import {useDeserializeEVM} from "deserialize-evm-client-sdk";
...
// rest of the componentimport {useDeserializeEVM} from "deserialize-evm-client-sdk";
// user wallet address must be passed
const {getBalance} =useDeserializeEVM("0x0abs...aaa");
return (<></>);example
// 0x3eC8A8705bE1D5ca90066b37ba62c4183B024ebf USDT token address
// (optional) you can pass a wallet address and get the token balance of the wallet address
await getBalance("0x3eC8A8705bE1D5ca90066b37ba62c4183B024ebf","0xaaaaaaaaaaaaaaaaaaaaaaaaaa");
// where you don't pass the user's wallet address, it would use the current connected
// note: a wallet address must already be connected
await getBalance("0x3eC8A8705bE1D5ca90066b37ba62c4183B024ebf");
Methods
loading
returns a boolean to indicate if a function is running or not
(async function) fetchTokens
fetches all tokens with available pools
(async function) getBalance(tokenAddress : string , walletAddress? : string)
if walletAddress is passed, it returns the token balance of that address otherwise it returns the token balance of whichever wallet address is connected
async swap(tokenIn : string , tokenOut : string , slippage : number , amountIn : string)
this executes the swap the amount in should be in human amount eg 10 , 0.1 , 0.0001
Releases
Changes would be recorded in the CHANGELOG.md
