const { data, error } = await supabase.auth.signUp({
email: '[email protected]',
password: 'password'
});
const { data, error } = await supabase.auth.signInWithPassword({
email: '[email protected]',
password: 'password'
});
const { data, error } = await supabase
.from('users')
.insert([
{
id: 'user_id',
email: '[email protected]',
full_name: 'John Doe',
user_type: 'student'
}
]);
const { data, error } = await supabase
.from('users')
.select('*')
.eq('id', 'user_id')
.single();
const { data, error } = await supabase
.from('credentials')
.insert([
{
issuer_id: 'issuer_id',
recipient_id: 'recipient_id',
title: 'Degree Title',
description: 'Description',
blockchain_tx_hash: 'tx_hash'
}
]);
const { data, error } = await supabase
.from('credentials')
.select(`
*,
issuer:users!credentials_issuer_id_fkey(*),
recipient:users!credentials_recipient_id_fkey(*)
`)
.or('issuer_id.eq.user_id,recipient_id.eq.user_id');
const address = await web3Service.connect();
const txHash = await web3Service.issueCredential(
recipientAddress,
credentialHash
);
const credential = await web3Service.verifyCredential(
credentialId
);
type User = {
id: string;
email: string;
full_name: string;
user_type: string;
wallet_address: string | null;
};
type Credential = {
id: string;
title: string;
description: string;
issue_date: string;
blockchain_tx_hash: string | null;
issuer: User;
recipient: User;
};
try {
const result = await apiCall();
} catch (error) {
if (error instanceof AuthError) {
// Handle auth errors
} else if (error instanceof DatabaseError) {
// Handle database errors
} else {
// Handle other errors
}
}
- Supabase: Depends on your plan
- Web3: Depends on the network