V1

Provider API is promise based, and user is expected to catch and handle errors, promises will resolve whenever possible or timeout after 3 minutes. Including confirmation window.


declare global {
	interface Window {
		z3us: {
			v1: {
				hasWallet: () => Promise<boolean>
				isConnected: () => Promise<boolean>
				connect: () => Promise<string>
				disconnect: () => Promise<void>
				sign: (challenge: string) => Promise<string>
				submitTransaction: (payload: { transaction: any }) => Promise<any>
				encrypt: (message: string, fromAddress: string, toAddress: string) => Promise<string>
				decrypt: (message: string, fromAddress: string) => Promise<string>
				addresses: () => Promise<string[]>
				balances: () => Promise<unknown>
				stakes: () => Promise<unknown>
				unstakes: () => Promise<unknown>
				/**
				* @deprecated Use submitTransaction() instead
				*/
				sendTransaction: (payload: { symbol: string; fromAddress: string; transaction: any }) => Promise<any>
			}
		}
	}
}
  

Error handling

To handle errors in a simple manner, use try/catch block, function will throw in case of action declined or unexpected error. There is a 3 minute timeout on the promise.


try {
	const response = await window.z3us.v1.balances()
} catch (error) {
	console.error(error)
}
  

Connecting

Prior to connecting, please verify that window.z3us is available and that user has initialised their wallet. To connect use window.z3us.v1.connect() which will return the currently selected address.


const hasWallet = await window.z3us?.v1.hasWallet()
if (!hasWallet) {
	return
}
const selectedAddress = await window.z3us.v1.connect()
  

Once the user authorises your website, the extension popup will not show again (unless they remove the permissions) and the connect method will return the selected address.

Disconnecting

Your website might be disconnected by the user, or you can call disconnect method, which will trigger extension popup again next time you call connect.


await window.z3us.v1.disconnect()
  

Z3US injects a global API into websites visited by its users at window.z3us. This API allows users to interact with wallet and Radix DLT.