Cardano

Cardano integration via OneKey's CIP-30 compatible provider

Integrate Cardano blockchain using OneKey's CIP-30 compatible provider. Access via window.cardano.onekey or window.cardano.nami.

OneKey implements CIP-30 (Cardano dApp Connector), ensuring compatibility with all Cardano dApps. It also provides Nami wallet compatibility.



Provider Detection

// OneKey provides both onekey and nami interfaces
const onekey = window.cardano?.onekey
const nami = window.cardano?.nami

// Check availability
if (!onekey) {
  throw new Error('OneKey Cardano provider not detected')
}

// Get wallet info
console.log('Name:', onekey.name) // 'OneKey'
console.log('API Version:', onekey.apiVersion) // '0.1.0'
console.log('Icon:', onekey.icon)

Quick Start

Enable Wallet

Check if Enabled


Account Information

Get Network ID

Get Balance

Get Addresses

Get UTxOs


Transactions

Sign Transaction

Submit Transaction

Complete Transaction Flow


Data Signing

Sign Data (CIP-8)

Sign arbitrary data for authentication:

Verify Signature


Event Handling

Listen for Account Changes


API Reference

Wallet Interface (CIP-30)

Property/Method
Description

name

Wallet name ('OneKey')

icon

Wallet icon URL

apiVersion

API version

isEnabled()

Check if enabled

enable()

Request wallet access

dApp API (after enable)

Method
Description

getNetworkId()

Get network (0=testnet, 1=mainnet)

getBalance()

Get total balance (CBOR)

getUtxos(amount?, paginate?)

Get UTxOs

getUsedAddresses()

Get used addresses

getUnusedAddresses()

Get unused addresses

getChangeAddress()

Get change address

getRewardAddresses()

Get staking addresses

signTx(tx, partialSign?)

Sign transaction

signData(addr, payload)

Sign data (CIP-8)

submitTx(tx)

Submit transaction

Experimental API

Method
Description

experimental.getCollateral()

Get collateral UTxOs

experimental.on(event, cb)

Subscribe to events

experimental.off()

Unsubscribe

Types

Events

Event
Description

accountChange

Account changed


Error Handling

Common Errors

Code
Description

-1

User rejected

-2

Account not found

-3

Invalid network


Using with Lucid

Lucid provides a simpler API:


Using with Mesh

Mesh is another popular Cardano SDK:


Nami Compatibility

OneKey provides Nami wallet compatibility:

Last updated

Was this helpful?