How to use the algosdk.Address.encode function in algosdk

To help you get started, we’ve selected a few algosdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BitGo / BitGoJS / modules / core / src / v2 / coins / algo.ts View on Github external
const txnForDecoding = decodedTx.txn || decodedTx;

        tx = Multisig.MultiSigTransaction.from_obj_for_encoding(txnForDecoding);
      } catch (ex) {
        throw new Error('txHex needs to be a valid tx encoded as base64 string');
      }

      const id = tx.txID();
      const fee = { fee: tx.fee };

      const outputAmount = tx.amount || 0;
      const outputs: { amount: number; address: string }[] = [];
      if (tx.to) {
        outputs.push({
          amount: outputAmount,
          address: Address.encode(new Uint8Array(tx.to.publicKey)),
        });
      }

      // TODO(CT-480): add recieving address display here
      const memo = tx.note;

      return {
        displayOrder: ['id', 'outputAmount', 'changeAmount', 'outputs', 'changeOutputs', 'fee', 'memo'],
        id,
        outputs,
        outputAmount,
        changeAmount: 0,
        fee,
        changeOutputs: [],
        memo,
      };