Giter Site home page Giter Site logo

mpc-script's Introduction

Overview

⚠️⚠️⚠️ Caution! This is beta / testnet technology ⚠️⚠️⚠️

Near's MPC allows a Near Account to create derivative accounts (public keys) and signatures of transactions for other blockchains.

Several MPC nodes maintain a single public key. This key is combined with your Near AccountId (unique) and a chosen "path" offset (chosen by client). This produces a new and unique public key. The generation of signatures via the MPC nodes can only be authorized by same Near Account by calling the sign method of the MPC contract.

The creation of secp256k1 public keys for Bitcoin and EVM chains is currently supported.

Flow (how it works)

  1. Obtain the MPC public key (near view [MPC_CONTRACT_ID] public_key) and hardcode into .env or code
  2. Choose a path for the derived account (public key) see: Path naming conventions
  3. Use ./src/kdf.ts -> generateAddress to generate the derived account address and public key
  4. Use the sign method of ./src/near.ts -> sign which calls the MPC contract to sign payload (hash of TX)
  5. Using a library (ethers/bitcoinjs-lib) combine the transaction and signature to create signed transaction
  6. Broadcast the transaction e.g. sendRawTransaction

Installation

yarn

CREATE .env FILE in root of project

NEAR_ACCOUNT_ID="[NEAR_TESTNET_ACCOUNT]"
NEAR_PRIVATE_KEY="[NEAR_ACCOUNT_PRIVATE_KEY]"
MPC_PATH="[MPC_PATH]"
MPC_CHAIN="[ethereum|bitcoin]"
MPC_CONTRACT_ID="multichain-testnet-2.testnet"
MPC_PUBLIC_KEY="secp256k1:4HFcTSodRLVCGNVcGc4Mf2fwBBBxv9jxkGdiW2S2CA1y6UpVVRWKj6RX7d7TDt65k2Bj3w9FU4BGtt43ZvuhCnNt"

For dogecoin testnet (link below)

TATUM_API_KEY=""

For MPC_PATH please refer to:

Path naming conventions

Prebuilt Commands

yarn start [commands]

Command List

  • -ea - ethereum addressm (EVM)
  • -ba - bitcoin testnet address
  • -da - dogecoin testnet address
  • -s - sign sample payload using Near account
  • -etx - send ETH
  • -btx - send BTC
  • -dtx - send DOGE (WIP - UNFINISHED)

Sending Options

  • -a, --amount - amount to send (ETH or sats)
  • -to, --to - destination address

References & Useful Links

Examples

Live Example - Near Testnet, Sepolia, Bitcoin Testnet

A frontend example you can run locally

Docs

Path naming conventions

Chain Signatures Docs

Chain Signatures Use Cases

MPC Repositories

MPC Repo

Faucets and API Keys

Sepolia Faucet

Bitcoin Testnet Faucet

For Dogecoin, you will need to register for Tatum API (free plan):

Dogecoin Tatum API and docs

Dogecoin Testnet Faucet

mpc-script's People

Contributors

mattlockyer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.