> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Para + M0 Integration

> Combine Para's embedded wallets with M0's programmable stablecoin infrastructure

Para's embedded wallets [provide seamless access to M0's programmable stablecoin infrastructure](https://blog.getpara.com/money-movement/). Build next-generation financial applications with custom digital dollars.

<CardGroup cols={2}>
  <Card title="M0 Documentation" href="https://docs.m0.org">
    Learn about M0's stablecoin protocol
  </Card>
</CardGroup>

## Prerequisites

* Para API key configured
* Node.js 18+ environment
* Understanding of stablecoin mechanics
* [M0 contract addresses](https://docs.m0.org/home/overview/) for your network

## Installation

<Steps>
  <Step title="Install packages">
    Install the required packages:

    ```bash theme={null}
    npm install @getpara/server-sdk @getpara/viem-v2-integration viem@^2
    ```
  </Step>
</Steps>

## Setup

<Steps>
  <Step title="Import dependencies">
    Import the required Para SDK and Viem components:

    ```typescript theme={null}
    import { ParaServer } from "@getpara/server-sdk";
    import { createParaViemClient, createParaViemAccount } from "@getpara/viem-integration";
    import { http } from 'viem';
    import { mainnet } from 'viem/chains';
    ```
  </Step>

  <Step title="Initialize Para SDK">
    Set up Para server instance:

    ```typescript theme={null}
    const para = new ParaServer(process.env.PARA_API_KEY);
    ```
  </Step>

  <Step title="Create wallet">
    Check for existing wallet or create new pregenerated wallet:

    ```typescript theme={null}
    const hasWallet = await para.hasPregenWallet({
      pregenId: { email: 'user@example.com' },
    });

    let pregenWallet;
    if (!hasWallet) {
      pregenWallet = await para.createPregenWallet({
        type: 'EVM',
        pregenId: { email: "user@example.com" },
      });
    }
    ```
  </Step>

  <Step title="Create Para account and client">
    Set up the account and Viem client for M0 interactions:

    ```typescript theme={null}
    const account = await createParaViemAccount(para);
    const client = createParaViemClient(para, {
      account,
      chain: mainnet,
      transport: http(),
    });
    ```
  </Step>
</Steps>

## Contract Configuration

### M0 Contract Addresses

```typescript theme={null}
const M_ADDRESS = '0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b';
const WM_ADDRESS = '0x437cc33344a0B27A429f795ff6B469C72698B291';
```

### Contract ABIs

```typescript theme={null}
const ERC20_ABI = [
  { name: 'approve', type: 'function', inputs: [{ name: 'spender', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'bool' }] },
  { name: 'transfer', type: 'function', inputs: [{ name: 'recipient', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'bool' }] }
];

const WM_ABI = [
  { name: 'wrap', type: 'function', inputs: [{ name: 'recipient', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'uint240' }] },
  { name: 'unwrap', type: 'function', inputs: [{ name: 'recipient', type: 'address' }, { name: 'amount', type: 'uint256' }], outputs: [{ type: 'uint240' }] }
];
```

## Usage

### Wrapping \$M to \$wM

<Steps>
  <Step title="Approve $M tokens">
    ```typescript theme={null}
    async function wrapMToWM(amount) {
      const approveHash = await client.writeContract({
        address: M_ADDRESS,
        abi: ERC20_ABI,
        functionName: 'approve',
        args: [WM_ADDRESS, amount]
      });
      console.log('Approve hash:', approveHash);
    ```
  </Step>

  <Step title="Wrap tokens">
    ```typescript theme={null}
      const wrapHash = await client.writeContract({
        address: WM_ADDRESS,
        abi: WM_ABI,
        functionName: 'wrap',
        args: [account.address, amount]
      });
      console.log('Wrap hash:', wrapHash);
    }
    ```
  </Step>
</Steps>

### Unwrapping \$wM to \$M

```typescript theme={null}
async function unwrapWMToM(amount) {
  const unwrapHash = await client.writeContract({
    address: WM_ADDRESS,
    abi: WM_ABI,
    functionName: 'unwrap',
    args: [account.address, amount]
  });
  console.log('Unwrap hash:', unwrapHash);
}
```

### Token Transfers

```typescript theme={null}
async function transferToken(tokenAddress, recipient, amount) {
  const transferHash = await client.writeContract({
    address: tokenAddress,
    abi: ERC20_ABI,
    functionName: 'transfer',
    args: [recipient, amount]
  });
  console.log('Transfer hash:', transferHash);
}
```

## Examples

### Basic Operations

```typescript theme={null}
await wrapMToWM(1000000n);
await unwrapWMToM(1000000n);
await transferToken(M_ADDRESS, '0xRecipientAddress', 1000000n);
```

## Next Steps

<CardGroup cols={2}>
  <Card title="M0 Documentation" href="https://docs.m0.org">
    Learn about M0's stablecoin protocol
  </Card>

  <Card title="Wallet Pregeneration" href="https://docs.getpara.com/integration-guides/wallet-pregeneration">
    Deep dive into wallet pregeneration
  </Card>
</CardGroup>

## Related Walkthroughs

<CardGroup cols={3}>
  <Card title="Aave v3 Integration" icon="landmark" href="/v3/walkthroughs/aave">
    Advanced · 45 min · Lending, borrowing, and yield strategies
  </Card>

  <Card title="Brale Integration" icon="coins" href="/v3/walkthroughs/brale">
    Beginner · 20 min · Stablecoin issuance API
  </Card>

  <Card title="Squid Router Integration" icon="arrows-split-up-and-left" href="/v3/walkthroughs/Squid">
    Advanced · 45 min · Cross-chain USDC bridges
  </Card>
</CardGroup>
