wip credential generation example

This commit is contained in:
Gala
2023-12-13 14:11:14 +01:00
committed by Jędrzej Stuczyński
parent 5881f6b6aa
commit ea6f009c01
3 changed files with 13 additions and 7 deletions
@@ -1,8 +1,6 @@
# mixFetch Usage Example
# Nym credential generation Usage Example
This is a simple project to show you how to use mixFetch.
Basic usage is as simple as replacing `fetch` with `mixFetch` in your code:
This is a simple project to show you how to use nym credential generation.
```ts
import { mixFetch } from '@nymproject/mix-fetch';
@@ -19,7 +19,7 @@
<h1>Credential</h1>
<input placeholder="mnemonic"></input>
<input placeholder="amount"></input>
<button onclick="getCredentials()">Get Credential</button>
<button id="button">Get Credential</button>
<div id="credential"></div>
</div>
</body>
@@ -4,10 +4,17 @@ import { appendOutput } from './utils';
async function main() {
const mnemonic = document.getElementById('mnemonic') as HTMLInputElement;
const coin = document.getElementById('coin') as HTMLInputElement;
const button = document.getElementById('button') as HTMLButtonElement;
const client = await createNymCredentialsClient({ isSandbox: true }); // options: {isSandbox?: boolean; networkDetails?: {}}
const credential = await client.comlink.acquireCredential(coin.value, mnemonic.value, {});
appendOutput(JSON.stringify(credential, null, 2));
const generateCredential = async () => {
const credential = await client.comlink.acquireCredential(coin.value, mnemonic.value, {});
appendOutput(JSON.stringify(credential, null, 2));
};
if (button) {
button.addEventListener('click', () => generateCredential());
}
}
// wait for the html to load
@@ -15,3 +22,4 @@ window.addEventListener('DOMContentLoaded', () => {
// let's do this!
main();
});