API refrence

Methods

rabet.connect()

To interact with the user's account in Rabet, you must first connect to it.

For connecting to the user account, you must send a connection request to the user. If the user confirms, you will receive the user account public key; otherwise, you will receive a rejected error.

interface ConnectResult {
    publicKey: string;
    error?: string;
}

rabet.connect(): Promise<ConnectResult>;
rabet.connect()
    .then(result => console.log(`User active public key is: ${result.publicKey}`))
    .catch(error => console.error(`Error: ${error}`));

rabet.sign()

To send an XDR to the connected account and let users sign it, you need to use this method.

interface SignResult {
    xdr: string;
    error: string;
}

rabet.sign(): Promise<SignResult>;
const network = StellarSdk.Networks.PUBLIC;
const XDR = 'AAAAA...;

rabet.sign(XDR, network)
    .then(result => {
        console.log(`I have the signed XDR here: ${result.xdr}`);
    })
    .catch(error => console.error(error));

rabet.disconnect()

This method removes the connection between the extension and the client. In order to interact with the extension, you need to call rabet.connect() again.

rabet.disconnect(): Promise<void>

rabet.isUnlocked()

This method returns a Promise that resolves to a boolean indicating if Rabet is unlocked by the user. Rabet must be unlocked in order to perform any operation involving user accounts. Note that this method does not indicate if the user has exposed any accounts to the caller.

rabet.isUnlocked(): Promise<Boolean>

rabet.close()

When calling rabet.connect() or rabet.sign() a new window shows up that lasts for 30 seconds, but use this method if you want to close that window manually.

rabet.close(): Promise<void>

Events

accountChanged

This event triggers whenever the user changes the active account in the extension wallet.

rabet.on('accountChanged', handler: () => void);

networkChanged

This event triggers whenever the user changes the network in the extension wallet.

rabet.on('networkChanged', handler: (networkId: string) => void);

Last updated