Integration with DeWallet Extension
Integration between DeWallet Extension and Web Application based on dispatching events.
Common object for event dispatcher:
{
method: “requestAccounts” | “generateSignature”, secretKey: 'deWallet-extension-event',
location: window.location.origin,
networkId: network id according to https://chainlist.org/
}
function connectWallet() { const dataObj = {
method: “requestAccounts”, secretKey: 'deWallet-extension-event', location: window.location.origin, networkId: 1 };
const storeEvent = new CustomEvent('myStoreEvent', {"detail":dataObj});
document.dispatchEvent(storeEvent); }
Detail response object for connect wallet {
success: boolean,
method: "responseRequestAccounts",
data: {
Address: string (wallet address) guildName: string (curator username) balance: IBalance[]
} | { error: string }
IBalance {
address: string (empty string means this is native currency) balance: string
chain: string (chain name) creationDate: number (timestamp) decimals: number
name: string
symbol: string
type: "ERC20" | “ERC721”
userId: string
_id: string
}
document.addEventListener(“extensionResponse”, (e: Event) => { const event = e as CustomEvent
// do whatever you need with event.detail })
Detail response for generate signature method
{success: boolean,
method: "responseGenerateSignature",
data: { signature: string } | { error: string } }
Last modified 9mo ago