Wallet for Aztec apps

ShieldSwap SDK allows you to connect your Aztec app to

https://wallet.shieldswap.org
.

WalletConnect modal

Installation

npm install --save @shieldswap/wallet-sdk@0.62.0
sh

Initialize Aztec PXE

import {  } from "@aztec/aztec.js";

const  = ("http://localhost:8080");
ts

Connect wallet

import {  } from "@shieldswap/wallet-sdk";

const  = new ();

// Opens a popup modal
const  = await .();
.("connected wallet", .().toString());
ts

Send a transaction

account is a drop-in replacement of @aztec/aztec.js AccountWallet. You can send a transaction as you would with an AccountWallet.

import {  } from "@aztec/aztec.js";
import {  } from "@aztec/noir-contracts.js/Token";

// Get currently selected account
const  = .();
if (!) throw new ("Wallet not connected");

// Deploy a token
const  = await .deploy(, .(), "My Token", "MTK", 18)
  .send()
  .deployed();
.("deployed token at address:", .address.toString());

// Mint some tokens to the wallet
const  = await 
  .withWallet()
  .methods.mint_public(.(), new (100))
  .send()
  .wait();
.("minted tokens. Tx hash", .txHash.toString());

// Check the balance
const  = await 
  .withWallet()
  .methods.balance_of_public(.())
  .simulate();
.(`balance of ${.()}:`, );
ts

React to user changing accounts

wallet.getAccount() returns the currently selected account. If you want to react to the user changing accounts, you can use the wallet.accountObservable:

<script>
  const account = wallet.accountObservable;
</script>

{#if $account}
  <p>Connected to {$account.getAddress().toString()}</p>
{:else}
  <p>Not connected</p>
{/if}
svelte