diff --git a/asset-close.html b/asset-close.html new file mode 100644 index 0000000..5317074 --- /dev/null +++ b/asset-close.html @@ -0,0 +1,564 @@ + + +
+ + ++ Connect to AlgoSigner +
+ +response
+ AlgoSigner.connect()
+.then((d) => {
+ ...
+})
+.catch((e) => {
+ console.error(e);
+});
+ + Gets the users TestNet accounts +
+ +response
+ AlgoSigner.accounts({
+ ledger: 'TestNet'
+})
+.then((d) => {
+ accounts = d;
+})
+.catch((e) => {
+ console.error(e);
+});
+ + Query AlgoD to get TestNet suggested TX Params +
+ +response
+ AlgoSigner.algod({
+ ledger: 'TestNet',
+ path: '/v2/transactions/params'
+})
+.then((d) => {
+ txParams = d;
+})
+.catch((e) => {
+ console.error(e);
+});
+ + Query Indexer to get TestNet assets +
+ +response
+ const name = document.getElementById("name").value;
+const limit = document.getElementById("limit").value;
+
+AlgoSigner.indexer({
+ ledger: 'TestNet',
+ path: `/v2/assets?name=${name}&limit=${limit}`,
+})
+.then((d) => {
+ document.getElementById("assets-code").innerHTML = JSON.stringify(d);
+})
+.catch((e) => {
+ console.error(e);
+ document.getElementById("assets-code").innerHTML = JSON.stringify(e);
+});
+ + Ask the user to sign an asset close transaction using AlgoSigner's Sign method +
+ +response
+
+ AlgoSigner.sign({
+ "from": document.getElementById("from").value,
+ "to": document.getElementById("to").value,
+ "assetIndex": +document.getElementById("asset").value,
+ "note": document.getElementById("note").value,
+ "amount": 0,
+ "type": "axfer",
+ "fee": txParams['min-fee'],
+ "firstRound": txParams['last-round'],
+ "lastRound": txParams['last-round'] + 1000,
+ "genesisID": txParams['genesis-id'],
+ "genesisHash": txParams['genesis-hash'],
+ "closeRemainderTo": document.getElementById("to").value,
+ })
+ .then((d) => {
+ signedTx = d;
+ })
+ .catch((e) => {
+ console.error(e);
+ });
+
+ + Send the previously signed transaction using AlgoSigner's Send method +
+ +response
+ AlgoSigner.send({
+ ledger: 'TestNet',
+ tx: signedTx.blob
+})
+.then((d) => {
+ tx = d;
+})
+.catch((e) => {
+ console.error(e);
+});
+ + Query the pending transaction endpoint to check the sent transaction status +
+ +response
+ AlgoSigner.algod({
+ ledger: 'TestNet',
+ path: '/v2/transactions/pending/' + tx.txId
+})
+.then((d) => {
+ console.log(d);
+})
+.catch((e) => {
+ console.error(e);
+});
+