ROLA is method of authenticating something claimed by the user connected to your dApp with the Radix Wallet. It uses the capabilities of the Radix Network to make this possible in a way that is decentralized and flexible for the user.
See for more information.
RadixAPI offers ROLA as a Service, so that you do not need to run your own ROLA server. To use ROLA, follow the steps below:
Create a challenge and pass this to your RadixDappToolkit
const getChallenge = async () => {
let challenge = '';
const params = {
'applicationName': 'Your dApp Name', // your dApp name as defined in the console
'dAppDefinitionAddress': 'account_xxx', // your dApp account address as defined in the console
'networkId': 1, // 1 = mainnet, 2 = testnet
'expectedOrigin': 'https://yourdomain.com', // the exact domain, use http://localhost:3000 for local development
'expires': 900 // 15 minutes in this case
};
try {
const requestOptionsRCV = {
method: "POST",
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': "Bearer " + process.env.RADIXAPI_BEARER,
},
body: JSON.stringify(params),
};
const result = await fetch(
'https://api.radixapi.net/v1/challenge/create',
requestOptionsRCV
).then((res) => res.json());
challenge = result.challenge;
} catch (error) {
console.log("Error during challenge/create: ", error);
}
return new Promise((resolve, reject) => {
resolve(challenge);
});
};