Add Wallet Users

Overview

Wallet admins can send wallet-user invitations to people in their enterprise who have a BitGo account. When you share a wallet with users in your enterprise, you can designate them with one of the following roles:

  • Admin - Able to initiate any wallet transactions, including adding, approving, and removing wallet users.
  • Spender - Able to initiate spend transactions.
  • Trader - Able to initiate trades for a Go Account.
  • Viewer - Able to view wallet balances, transactions, and wallet metadata (such as other wallet users).

Prerequisites

Create Wallet Share

Endpoint: Create a wallet share

export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export MESSAGE="<MESSAGE_TO_THE_INVITEE>"
export USER="<INVITEE_USER_ID>"

curl -X POST \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/share \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "permissions": "spend,view",
    "message": "'"$MESSAGE"'",
    "user": "'"$USER"'",
    "keychain": {        # Enables the wallet spender to sign with their passphrase
      "pub": "string",
      "encryptedPrv": "string",
      "fromPubKey": "string",
      "toPubKey": "string",
      "path": "m/1234/1/1"
  }
}'
import { BitGoAPI } from '@bitgo/sdk-api';
import { Btc, Tbtc4 } from '@bitgo/sdk-coin-btc';

const bitgo = new BitGoAPI({
  accessToken: '<access_token>',
  env: 'test',
});

const coin = 'tbtc4';
bitgo.register(coin, Tbtc4.createInstance);

// Set the id of the wallet to share.
const walletId = null;

// Set BitGo account email of wallet share recipient.
const recipient = null;

// Set share permissions as a comma-separated list (e.g. 'view,spend').
// Valid permissions to choose from are: view, spend, manage, admin.
const perms = 'view';

// Provide the passphrase for the wallet being shared
const passphrase = null;

async function main() {
  const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });

  const shareResult = await wallet.shareWallet({
    email: recipient,
    walletPassphrase: passphrase,
    permissions: perms,
  });

  console.log('Wallet was shared successfully');
  console.dir(shareResult);
}

main().catch(error => console.log(error))

Step Result

{
  "id": "string",
  "coin": "string",
  "wallet": "string",
  "walletLabel": "My Wallet",
  "fromUser": "string",
  "toUser": "string",
  "permissions": "spend,view",
  "message": "string",
  "state": "active",
  "enterprise": "string",
  "pendingApprovalId": "string",
  "keychain": {
    "pub": "string",
    "encryptedPrv": "string",
    "fromPubKey": "string",
    "toPubKey": "string",
    "path": "m/1234/1/1"
  }
}

See Also