Check AlgoSigner See code on GitHub

Check if AlgoSigner library is available

response
if (typeof AlgoSigner !== 'undefined') {
  document.getElementById('check-code').innerHTML = 'AlgoSigner is installed.';
} else {
  document.getElementById('check-code').innerHTML = 'AlgoSigner is NOT installed.';
};

Connect See code on GitHub

Connect to AlgoSigner

response
AlgoSigner.connect()
.then((d) => {
  document.getElementById('connect-code').innerHTML = JSON.stringify(d);
})
.catch((e) => {
  console.error(e);
  document.getElementById('connect-code').innerHTML = JSON.stringify(e);
});

SDK Setup See code on GitHub

Setup client for algosdk

response
const algodServer = 'https://testnet-algorand.api.purestake.io/ps2'
const indexerServer = 'https://testnet-algorand.api.purestake.io/idx2'
const token = { 'X-API-Key': 'YOUR API KEY HERE' }
const port = '';

algodClient = new algosdk.Algodv2(token, algodServer, port);
indexerClient = new algosdk.Indexer(token, indexerServer, port);

algodClient.healthCheck().do()
.then(d => { 
  ... 
})
.catch(e => { 
  console.error(e); 
});

Get TestNet Accounts See code on GitHub

Gets the users TestNet accounts

response
AlgoSigner.accounts({
  ledger: 'TestNet'
})
.then((d) => {
  document.getElementById('accounts-code').innerHTML = JSON.stringify(d);
})
.catch((e) => {
  console.error(e);
  document.getElementById('accounts-code').innerHTML = JSON.stringify(e);
});

Status See code on GitHub

Query AlgoD to get TestNet status

response
algodClient.status.do()
.then((d) => {
  document.getElementById('status-code').innerHTML = JSON.stringify(d);
})
.catch((e) => {
  console.error(e);
  document.getElementById('status-code').innerHTML = JSON.stringify(e);
});

Get Assets from Indexer See code on GitHub

Query Indexer to get TestNet assets

response
const name = document.getElementById('name').value;
const limit = document.getElementById('limit').value;

indexerClient.searchForAssets()
.limit(limit)
.name(name)
.do()
.then((d) => {
  document.getElementById('assets-code').innerHTML = JSON.stringify(d);
})
.catch((e) => {
  console.error(e);
  document.getElementById('assets-code').innerHTML = JSON.stringify(e);
});