Use ROLA
Rola as a Service
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);
});
};Last updated