const ISSUER = 'https://account.bitski.com';
const { BITSKI_CREDENTIAL_ID, BITSKI_CREDENTIAL_SECRET } = platform.env;
export async function createAccount(userId: string): Promise<string[]> {
var credentials = btoa(`{BITSKI_CREDENTIAL_ID}:{BITSKI_CREDENTIAL_SECRET}`);
// Use client credentials to create a wallet for your user.
// The `userId` here can be any string to identify the user.
const newAccount = await fetch(`${ISSUER}/v2/federated-accounts`, {
method: 'POST',
headers: {
authorization: `Basic ${credentials}`,
'User-Agent': 'account-creation-example/1.0.0',
'content-type': 'application/json',
},
body: JSON.stringify({
userId,
}),
});
// The response contains an etherum `0x` address
const { accounts } = await newAccount.json();
return accounts;
}