Chroma

Talisman

Testing with Talisman wallet extension

Talisman is a popular multi-chain wallet for the Polkadot ecosystem. Chroma provides full support for automating Talisman wallet interactions.

Setup

Create a test with Talisman wallet using createWalletTest:

import { createWalletTest } from '@avalix/chroma'

const test = createWalletTest({
  wallets: [{
    type: 'talisman'
  }]
})

test('talisman test', async ({ wallets }) => {
  const talisman = wallets.talisman
})

Import Account

Import Polkadot Mnemonic

Import a Polkadot account using a mnemonic seed phrase:

await talisman.importPolkadotMnemonic({
  seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
  name: 'My Test Account',
})

Import Private Key

Import an EVM account using a private key:

await talisman.importPrivateKey({
  privateKey: '0x...',
  name: 'My EVM Account',
})

Authorize Connection

When your dApp requests wallet access, specify the account name to authorize:

// Your dApp triggers a connection request
await page.click('button:has-text("Connect Wallet")')

// Approve the request with account name
await talisman.authorize({ accountName: 'My Test Account' })

Approve Transaction

When your dApp requests transaction signing:

// Your dApp triggers a transaction
await page.click('button:has-text("Submit")')

// Approve the transaction
await talisman.approveTx()

To reject a transaction:

await talisman.rejectTx()

EVM Support

Talisman supports Ethereum-compatible chains. Use the same methods for EVM transactions:

import { createWalletTest } from '@avalix/chroma'

const test = createWalletTest({
  wallets: [{
    type: 'talisman'
  }]
})

test('evm transaction', async ({ page, wallets }) => {
  const talisman = wallets.talisman
  
  await talisman.importPrivateKey({
    privateKey: '0x...',
    name: 'My EVM Account',
  })
  
  await page.goto('http://localhost:3000')
  await talisman.authorize({ accountName: 'My EVM Account' })
  
  // EVM transaction
  await page.click('button:has-text("Send ETH")')
  await talisman.approveTx()
})

Complete Example

tests/talisman.spec.ts
import { createWalletTest, expect } from '@avalix/chroma'

const test = createWalletTest({
  wallets: [{
    type: 'talisman'
  }]
})

test.describe('Talisman Wallet', () => {
  test.beforeEach(async ({ wallets }) => {
    const talisman = wallets.talisman
    await talisman.importPolkadotMnemonic({
      seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
      name: 'My Test Account',
    })
  })

  test('connect and transfer', async ({ page, wallets }) => {
    const talisman = wallets.talisman

    await page.goto('http://localhost:3000')
    await page.click('button:has-text("Connect")')
    await talisman.authorize({ accountName: 'My Test Account' })

    await expect(page.locator('.connected')).toBeVisible()

    await page.fill('input[name="amount"]', '1.0')
    await page.click('button:has-text("Send")')
    await talisman.approveTx()

    await expect(page.locator('.success')).toBeVisible()
  })

  test('multi-chain support', async ({ page, wallets }) => {
    const talisman = wallets.talisman

    await page.goto('http://localhost:3000')
    await talisman.authorize({ accountName: 'My Test Account' })

    // Switch to Ethereum chain in your dApp
    await page.click('button:has-text("Switch to Ethereum")')
    
    // Talisman handles EVM transactions
    await page.click('button:has-text("Send ETH")')
    await talisman.approveTx()
  })
})

Troubleshooting

Extension not loading

Make sure you've downloaded the extensions:

npx chroma download-extensions

Increase the timeout in your test:

test.setTimeout(60000)

Account not found

Ensure the account is imported before interacting with the dApp:

// Import FIRST
await talisman.importPolkadotMnemonic({ seed: '...', name: 'My Account' })

// THEN navigate to dApp
await page.goto('http://localhost:3000')

On this page