ProductsAppsFor Business

Coins

Support

Blog

Docs

Highlander

Building Chaac A Mayachain Wallet with KeepKey SDK.

Building Chaac A Mayachain Wallet with KeepKey SDK.

Building Chaac A Mayachain Wallet with KeepKey SDK

Using Vercel to build, deploy publish a Mayachain wallet

Building Chaac A Mayachain Wallet

TLDR: repo https://github.com/keepkey/Maya-dApp

URL: https://maya-d-app.vercel.app/

Overview

  • Getting Started with the next template
  • Adding the keepkey packages
  • Overview on mounting the wallet
  • Pairing Process
  • Sending CACAO
  • Publishing to Vercel

Getting Started

Clone the repo locally:

https://github.com/keepkey/Maya-dApp

Run it:

pnpm i pnpm run dev

Wallet Packages

Wallet Packages

Mounting the wallet:

const chains = ['MAYA']; // Example chains // @ts-ignore const { keepkeyWallet } = await import('@coinmasters/wallet-keepkey'); const walletKeepKey: KeepKeyWallet = { type: 'KEEPKEY', icon: 'https://pioneers.dev/coins/keepkey.png', chains, wallet: keepkeyWallet, status: 'offline', isConnected: false, MAYA: {} };

KeepKey config:

let keepkeyConfig = { apiKey: localStorage.getItem('keepkeyApiKey') || '123', pairingInfo: { name: "Maya Wallet", imageUrl: "https://i.pinimg.com/originals/24/77/56/247756ac928c5f60fc786aef33485f17.jpg", basePath: 'http://localhost:1646/spec/swagger.json', url: 'http://localhost:1646', } }

These config params are used during pairing.

KeepKey App Pairing

More information on KeepKey app pairing: Understanding The KeepKey REST API

Viewing Addresses and Balances

Reviewing the KeepKey wallet instance class:

const wallet = keepkeyInstance['MAYA'].wallet;

Wallet Object:

wallet: { address: "maya1g9el7lzjwh9yun2c4jjzhy09j98vkhfxfqkl5k", walletType: "KEEPKEY", balance: [ AssetValue { bigIntValue: 302513052572n, decimalMultiplier: 10000000000n, decimal: 10, address: undefined, chain: "MAYA", isGasAsset: true, isSynthetic: false, symbol: "CACAO", tax: undefined, ticker: "CACAO", type: "Native" }, AssetValue { bigIntValue: 41040000n, decimalMultiplier: 100000000n, decimal: 4, address: undefined, chain: "MAYA", isGasAsset: false, isSynthetic: false, symbol: "CACAO", tax: undefined, ticker: "CACAO", type: "Native" } ] }

The walletMethods object:

wallet = { deposit: async (param) => { ... }, getAccount: (e) => { ... }, getAddress: () => { ... }, getBalance: async (e) => { ... }, getFees: async () => { ... }, sendRawTransaction: async (e) => { ... }, transfer: async (param) => { ... } };

To get your address:

setWalletAddress(wallet.address);

View balances:

wallet.balances[0].getValue('string')

More about AssetValue Class

Serialize and deserializing values with AssetValue class.

Encode 500 as MAYA:

let assetString = 'MAYA.MAYA' await AssetValue.loadStaticAssets(); const assetValue = AssetValue.fromStringSync(assetString, parseFloat("500"));

Decode AssetValue to string:

assetValue?.getValue('string') // output "500"

Sending CACAO

hooks/useTransfer.tsx

let sendPayload = { assetValue, memo, recipient: destination, }; const txHash = await keepkeyInstance.MAYA.walletMethods.transfer(sendPayload);

The AssetValue Package

const assetString = `MAYA.${asset}`; await AssetValue.loadStaticAssets();

The assetString is in THORChain asset notation. For more information, review THORChain Dev Docs.

Publishing Apps to Vercel

Full guide: https://vercel.com/docs/getting-started-with-vercel

Publishing to Vercel

  1. Push your repo to GitHub
  2. “Add project”
  3. Vercel will assign a domain name to your project and host your site without cost!