x-vault
v3.1.16
Published
With X-vault, users do not need to manually enter private keys or seed phrases into a dApp, reducing the risk of exposing sensitive information. Instead, the user simply needs to scan a QR code to establish a secure connection between their wallet and the
Readme
x-vault
Install
npm i x-vaultUsage
import React from 'react'
import { XvaultProvider } from 'x-vault'
import { nftAbi } from "YOUR ABI PATH";
const App = () => {
const ContractAddress = {"Your contract address."};
const [session_id,setSession] = React.useState()
const [UserDetail,setUser] = React.useState()
React.useEffect(() => {
CreateConnection()
},[])
//This function will initialize your connection
//and will get you session id after scan qr code.
const CreateConnection =async()=>{
await XvaultProvider.connect().then((res)=>{
//store your session in variable
console.log("you will get session id here",res.session_id);
setSession(res.session_id)
})
}
//get user detail
const getUserDetail =async(sessionId)=>{
XvaultProvider.getUserInfo(sessionId).then((res)=>{
console.log("You will get userdetail==",res);
})
}
//user detail method end
//make payment method
const payment =()=>{
let data=
{ amount: parseFloat(PRICE) > 0 ? parseFloat(PRICE) : 0,
chain_id: {"YOUR CHAIN ID"},
contract_address:ContractAddress,
contract_abi:JSON.stringify(nftAbi),
method: {"METHOD NAME"},
//your blockchain method parameters
parameter:[ContractAddress, NFTID.. etc],
session_id:{"YOUR SESSION ID"},
}
XvaultProvider.SendPayment(data).then((res)=>{
res.on('passHash', (hash) => {
console.log("retun=hash=>>>>>==",hash)
})
res.on('paymentresponse', (callback) => {
console.log("payment response is=xxx=>>>==>",callback)
})
res.on('error', (error) => {
console.log("error event is here>>>>>==>",error)
})
});
}
//payment method end
//disconnect
const disconnect =async(sessionId)=>{
await XvaultProvider.disconnect(sessionId).then((res)=>{
window.location.reload()
})
}
//disconnect method end
return(<>
{session_id?
<>
<button onClick={()=>paymentCall("YOUR SESSION ID")}>payNow</button>
<button onClick={()=>getUserDetail("YOUR SESSION ID")}>UserDetail</button>
<button onClick={()=>disconnect("YOUR SESSION ID")}>disconnect</button>
</>
:
<XvaultProvider.QrcodeModal app_name={"Your App Name"} app_logo={"Your App logo public path"} />}
</>)
}
export default App
