MOSS Authentication
Core SDK Flow
import { mega } from '@megaeth-labs/wallet-sdk';
await mega.initialise({ network: 'mainnet' });
const auth = await mega.authenticate();
if (auth.status === 'success' && auth.jwt) {
await fetch('/api/auth/moss', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ jwt: auth.jwt }),
});
}React SDK Flow
function AuthButton() {
const authenticate = useAuthenticate();
return (
<button
onClick={() =>
authenticate.mutate(undefined, {
onSuccess: async (result) => {
if (result.status === 'success' && result.jwt) {
await fetch('/api/auth/moss', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ jwt: result.jwt }),
});
}
},
})
}
>
Authenticate with MOSS
</button>
);
}Response Contract
Backend Verification
Coming Soon
Related
Last updated