Rabet | Docs
Search…
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.
1
interface ConnectResult {
2
publicKey: string;
3
error?: string;
4
}
5
6
rabet.connect(): Promise<ConnectResult>;
Copied!
1
rabet.connect()
2
.then(result => console.log(`User active public key is: ${result.publicKey}`))
3
.catch(error => console.error(`Error: ${error}`));
Copied!

rabet.sign()

To send an XDR to the connected account and let users sign it, you need to use this method.
1
interface SignResult {
2
xdr: string;
3
error: string;
4
}
5
6
rabet.sign(): Promise<SignResult>;
Copied!
1
const network = StellarSdk.Networks.PUBLIC;
2
const XDR = 'AAAAA...;
3
4
rabet.sign(XDR, network)
5
.then(result => {
6
console.log(`I have the signed XDR here: ${result.xdr}`);
7
})
8
.catch(error => console.error(error));
Copied!

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.
1
rabet.disconnect(): Promise<void>
Copied!

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.
1
rabet.isUnlocked(): Promise<Boolean>
Copied!

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.
1
rabet.close(): Promise<void>
Copied!

Events

accountChanged

This event triggers whenever the user changes the active account in the extension wallet.
1
rabet.on('networkChanged', handler: () => void);
Copied!

networkChanged

This event triggers whenever the user changes the network in the extension wallet.
1
rabet.on('networkChanged', handler: (networkId: string) => void);
Copied!
Last modified 1mo ago