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.
- Obtain the MPC public key (near view [MPC_CONTRACT_ID]
public_key
) and hardcode into.env
or code - Choose a path for the derived account (public key) see: Path naming conventions
- Use
./src/kdf.ts -> generateAddress
to generate the derived account address and public key - Use the
sign
method of./src/near.ts -> sign
which calls the MPC contract to sign payload (hash of TX) - Using a library (ethers/bitcoinjs-lib) combine the transaction and signature to create signed transaction
- Broadcast the transaction e.g.
sendRawTransaction
yarn
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"
TATUM_API_KEY=""
yarn start [commands]
- -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)
- -a, --amount - amount to send (ETH or sats)
- -to, --to - destination address
Live Example - Near Testnet, Sepolia, Bitcoin Testnet