MobileCoin
MobileCoin Provider

MobileCoin-specific operations.

Direct access to wallet state, balances, message signing, and DEQS swaps through the MobileCoin provider.

Provider access

JavaScript
const mc = window.fire.mobilecoin;

Connect

JavaScript
const { address, connected } = await mc.request({ method: 'mc_connect' });

Wallet state

JavaScript
const state = await mc.request({ method: 'mc_getWalletState' });
// → { state: 'locked' | 'syncing' | 'ready' | 'unavailable' }

Balances

JavaScript
const { balance } = await mc.request({
  method: 'mc_getBalance',
  params: { token_id: 0 }  // 0 = MOB, 1 = eUSD
});

Sign messages

JavaScript
const { signature } = await mc.request({
  method: 'mc_signMessage',
  params: { message: 'Hello from my dApp' }
});

DEQS swaps

The decentralized exchange (DEQS) enables MOB/eUSD swaps directly through the wallet.

Get swap quotes

JavaScript
const quotes = await mc.request({
  method: 'deqs_getQuotes',
  params: { direction: 'mob_to_eusd' }
});
// → { rate, depth, quoteCount, online }

Execute a swap

JavaScript
const { tx_hash, status } = await mc.request({
  method: 'deqs_requestSwap',
  params: { direction: 'mob_to_eusd', amount: '1000000000000' }
});

Create a maker offer

JavaScript
const { offer_id } = await mc.request({
  method: 'deqs_createOffer',
  params: {
    token_id: 0,
    amount: '5000000000000',
    rate: '0.15',
    partial_fill: true,
    min_fill: '100000000000'
  }
});

Cancel an offer

JavaScript
await mc.request({
  method: 'deqs_cancelOffer',
  params: { offer_id: 'abc123' }
});

List your offers

JavaScript
const { offers } = await mc.request({ method: 'deqs_getOffers' });

Events

JavaScript
mc.on('accountChanged', ({ address }) => { /* ... */ });
mc.on('walletStateChanged', ({ state }) => { /* ... */ });
mc.on('disconnect', () => { /* ... */ });