Skip to main content

Quickstart SDK

The goal of this page is to get you from Zero to INTU MPC Account. Created from a user's existing Web3 Account.

Setup

Import INTU SDK in index.js and setup provider

App.jsx
import { ethers } from "ethers";
import {
vaultCreation,
automateRegistration,
preRegistration,
registerAllSteps,
completeVault,
combineSignedTx,
submitTransaction,
getVaults
} from "@intuweb3";
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = await provider.getSigner();
const signerAddress = await provider.getSigner().getAddress();
//define cosigners
const coSigner1 = "0x1111111111111111111111111111111111111111";
const coSigner1 = "0x2222222222222222222222222222222222222222";

Then, retrieve the user's INTU accounts (if any):

App.jsx
const userVaults = getVaults(signerAddress, web3Prprovidervider);
console.log(userVaults);

If the user doesn't yet have an INTU MPC account, lets create a new one!

Propose an account

import { createIntuAccount } from "@intuweb3/web-exp";
/*
The first parameter to pass is an array of the addresses that should be a part of this new vault
RotateThreshold = % of participants required to add or remove someone from the vault
TransactionThreshold = % of participants required to send a transaction from the vault
AdminThreshold = % of participants required to change a threshold %, change the name, etc.
*/
await createIntuAccount([0x1, 0x2, 0x3],
"MyEasyToReadVaultName",
rotateThreshold,
txThreshold,
adminThreshold,
signer)

Register each user in the account

Have each user register into the account

*Note, each step of the process (preRegister, automateRegistration, registerAllSteps) has to be completed by each user before the next step can be completed

*Everyone must perform pre-registration before registration step1 can be performed, etc.

import { preRegistration, registerStep1, registerStep2, registerStep3, completeVault, getVaults } from "@intuweb3/web-exp";
let myVaults = getVaults("0x12345_user_address", provider);
await preRegistration(vaultAddress, signer);
//then
await automateRegistration(vaultAddress, signer):
//then
await registerAllSteps(vaultAddress, signer);

Complete account

Here we confirm each user in the account, and determine the master public address (EOA) for the MPC account, and lock it in on the blockchain.

//JUST ONE USER NEEDS TO PERFORM THIS FUNCTION
await completeVault(vaultAddress, signer); // just once

Use it! Submit,

  let submitTx = async (myVaultAddress, myVaultEoa) => {

let chainId = "42161";
let value = "0.000001";
let to = "0x111111111111111111111111111111111111111";
let gasPrice = "11000000";
let gas = "1000000";
let nonce = 1;
let data = "";

try {
await submitTransaction(to, value, chainId, nonce, data, gasPrice, gas, myVaultAddress, intuSigner).then(async (res) => {
let result = res.wait();
let txId=1;
//User + another co-signer needs to sign
await signTx(myVaultAddress, txId, intuSigner);
//FUND ACCOUNT OR USE A PAYMASTER
.then((response) => console.log(response.text()))
.catch((error) => console.log("error", error));
combineSignedTx(currentVault, myVaultAddress, 1)
})
} catch (e) {
console.error(e);
}
};