Skip to main content

Install and initialize the SDK

Overview

This guide shows how to install and initialize the MPC (multi-party computation) SDK for supported clients, which include JavaScript web apps and Unity projects.

Document structure

To cater to developers of different backgrounds and experience levels, the guides in our MPC documentation have three different tabs with instructions and code examples for each client type:

  • The Core tab covers the use of the mpcCore provider in the MPC JavaScript SDK and is meant for beginner web3 developers who wish to implement the essential MPC features.
  • The Providers tab describes the use of the mpcProvider option that inherits the methods of other providers, such as Web3.js or Ethers.js, making it ideal for experienced web3 developers.
  • The Unity tab contains the instructions and code examples for Unity developers integrating their blockchain-enabled games with MPC.
About provider options in MPC JavaScript SDK

To facilitate integration for developers of varying backgrounds, the MPC JavaScript SDK offers two distinct provider options:

  • mpcCore is designed for developers with little web3 experience. It offers essential methods for main operations, such as creating wallets and signing transactions and messages through MPC.
  • mpcProvider offers familiar methods for experienced developers that have already used libraries, such as Ethers.js or Web3.js, and offers some other benefits:
    • Seamless integration with existing projects built on Web3Provider, Ethers.js, or custom EIP-1193 providers.
    • Minimum syntax changes: Retain your current syntax as mpcProvider automatically handles logic conversion for default methods.

Quickstart

Explore the various MPC features and get a feel for how it can benefit your web app: xdemo.vercel.app.

Prerequisites

  • Complete the steps in Get started.
  • Install the dependencies:
    • Node.js v18.16 or later
    • npm or Yarn for package installation

Install

Install the MPC JS SDK using npm:

npm install @axieinfinity/mpcjs

Or using Yarn:

yarn add @axieinfinity/mpcjs

Initialize

Import the MpcCore package:

import { MpcCore } from "@axieinfinity/mpcjs";

Initialize MpcCore:

import { MpcCore } from "@axieinfinity/mpcjs";

const mpcCore = MpcCore.init({
domain: `${YOUR_SERVER_DOMAIN}`, // "project-x.skymavis.one",
rpcURL: `${NETWORK_RPC}`, // "https://saigon-testnet.roninchain.com/rpc"
secure: `${boolean}`, // true (default)
});
//...

Parameters:

NameTypeDescription
domainStringDomain to interact with the backend and keystore.
rpcURLStringRPC (remote procedure call) URL of the blockchain network.
secureBoolPreferred protocol: true for secure wss (use in the production environment) or false for insecure wss (use in the development environment only). Defaults to true.

Example:

import { MpcCore } from "@axieinfinity/mpcjs";

const mpcCore = MpcCore.init({
domain: "project-x.skymavis.one",
rpcURL: "https://saigon-testnet.roninchain.com/rpc",
secure: true,
});
///...

Next steps

Create an MPC wallet

Was this helpful?
Happy React is loading...