API

For encoding, we use the standard function:

export function encodeStringToBase64(str: string) {
  return btoa(str)
}

Login:

const uuid = uuid()
wsConnect(uuid)
const data = JSON.stringify({
  type: 'login',
  uuid,
})
window.location.href = `namada:${encodeStringToBase64(data)}`

To send transactions, you can use this schema. type - transaction type. formDataObject - arguments

const uuid = uuid()
wsConnect(uuid)
const data = JSON.stringify({
  type: 'ibc-transfer',
  uuid,
  wallet: wallet.alias,
  formDataObject: {
    'source': wallet.alias,
    'receiver': cosmosWallet,
    'token': 'nam',
    'amount': amount,
    'channel-id': 'channel-31',
  },
})
window.location.href = `namada:${encodeStringToBase64(data)}`

To fetch shielded balance:

const uuid = uuid()
wsConnect(uuid)
const data = JSON.stringify({
  type: 'balance',
  wallet: "znam....",
  uuid,
})
window.location.href = `namada:${encodeStringToBase64(data)}`

Last updated