passkey-account-dapp
v1.1.9
Published
The sdk package provides a simple support connect Smart account for dapp.
Downloads
1,270
Readme
Account Passkey connect dapp
The sdk package provides a simple support connect Smart account for dapp.
Install (for single position)
npm install --save passkey-account-dapp
yarn add passkey-account-dapp
Usage
//use for version laster
import React, { useState, useEffect } from "react";
import ProviderDapp from "passkey-account-dapp";
const LayoutProvider = () => {
return (
<ProviderDapp
isDuplicateDomain={false} //for development
urlActiveAccount={...} //url Parent App
>
// code...
///.....
</ProviderDapp>
)
}
import { useChainSupport, useConnect, TYPE_ERROR_DAPP, useSendTransactions, TYPE_METHOD_DAPP } from "passkey-account-dapp";
//TYPE_METHOD_DAPP // event support
const ExampleDapp = () => {
//code ...
const [chainId, setChainId] = useState(137);
const { connect, data, error, logout, isConnected ,loading: loadingConnect} = useConnect();
const {
sendTransactions,
error: errorSendToken,
data: hashTx,
loading: loadingSendTx
} = useSendTransactions(chainId);
const {data: lisChainSupport, requestGetListChain}= useChainSupport()
//code....
const handleSend = (second) => {
//code....
const rawTransactions = {
amount:'1', //Amount ETH
to: '0x...', // The contract address, not the recipient's address
value: '0x0', // No ETH value is sent
data: '0x', // data hex
chainId: chainId //number
}
sendTransactions(rawTransactions)
//code....
}
return (
// code...
///.....
)
};
export default ExampleDapp;
License
MIT © HoDienCong12c5