# Wallets

# Accessing wallet data

You must have Pali Wallet installed before proceeding. See Getting Started. Once you have Pali Wallet installed and retrieved the controller object you can make function calls through it, e.g.:

>> output

Or in case functions are asynchronous, you can then use methods such as .then() or async to produce Promise Chains. Such as

if (controller) {
  await controller.connectWallet();

# onWalletUpdate()

To send the current data data to the webpage every time the wallet state is updated, you can call onWalletUpdate() and pass a callback to it to set up the new state or execute anything you want. This is needed to guarantee that the wallet information is consistent with the most recent state on the network.

const [connectedAccountAddress, setConnectedAccountAddress] = useState('');

const setup = async () => {
  if (controller) {
    const account = await controller.getConnectedAccount();


    console.log(`current address after a state update: ${account.address.main}`);
await controller.onWalletUpdate(setup);

# connectWallet()

You can connect to your wallet by executing connectWallet(). This is a standard async() function that waits for a Promise. As in the Getting Started section, it can be linked to a const variable and return a boolean value. When executed, your wallet extension should open and ask for a password.


You will then be asked to select which account you wish to connect to the DApp.

After the first execution, it will shift to asking if you want to change your Account.


# getConnectedAccount()

This function sends the connected account data to the page that called the function. It is an asynchronous function as well. Please refer to Getting Started for an example.

# getWalletState()

This function returns information about the Wallet. It is a async() function, which will give you two main outputs: The first one gives you information about the event; The latter is the actual wallet data.

When probing for account activity, this function can be called for some boolean results on what your user is up to. For example:

  • Is your wallet issuing or creating an NFT or an Asset?
  • Is it waiting for transactions to be confirmed?

Other information like balance, transactions, and so on, can be accessed.

Let's analyse a typical output:

await controller.getWalletState();

>> event result
>> { type: 'SEND_STATE_TO_PAGE', target: 'connectionsController', ... }
>> { status: 1623871791932, accounts: Array(1), activeAccountId: 0, activeNetwork: "testnet", ... }

Let's unpack this. On the second outcome under the first item of your Array you will see information such as:

address: {
  main: "addresshash"
assets: [{...}, ..., {...}]
balance : 0
connectedTo: ['localhost:port']
id : 0
isTrezorWallet: false
label: 'Account 1'
transactions : Array()

The transactions Array will give you information including txid, tokenType, fees, value, and so on.

# getUserMintedTokens()

This asynchronous function is straightforward. It is called with an empty value. Calling it returns an array containing all tokens the user has created as an object:

>> { assetGuid: "number", symbol: "Token name", maxSupply: number, totalSupply: number }

# isValidSYSAddress()

An asynchronous function that returns a boolean based on the address and checks if it is a valid based on the address convention for the network you are using (either Mainnet or Testnet). Its inputs are only the address as a string:

isValidSYSAddress(address: 'string')

The string is the address you wish to check for validity.

# getHoldingsData()

This asynchronous function returns an array of objects describing each asset held in the Wallet:

  type: "SPTAllocated",
  decimals: 1,
  symbol: "Token name",
  assetGuid: "142845519",
  baseAssetID: "142845519",
  childAssetID: null,
  nftAssetID: null,
  NFTID: "0",
  description: ''

If you are now wondering the difference between assetGuid and baseAssetID, please check the specifics in the Glossary.

# isLocked()

This function is pretty straight forward. It is an asynchronous function that returns a boolean value determining if the wallet is locked (true) or unlocked (false).

# getConnectedAccountXpub()

This function is also called with an empty value. It should return the current account extended public key.

The Xpub is used to derive child public keys, according to the BIP 32 standard of the Bitcoin blockchain.

# getChangeAddress()

This function can be called with an empty value.

When a wallet makes a transaction on the bitcoin blockchain it always transfers all of its assets in its wallet in one take. This means that, when a user sends tokens to someone, it actually sends a part of his belongings to the actual receiver and sends the rest to himself on the same transaction. The address that receives the surplus is called the change address.


However, the change address does not need to be the same wallet that began the transaction. One could choose to transfer money to someone and at the same time transfer all his holdings to another wallet. For a better understanding check UTXO (opens new window)

This function is most useful when dealing directly with the syscoin-libjs. Please check sign and Send transactions in this documentation for a useful case.