Crypto-as-a-Service: Create Go Account - Step by Step
Generate Go Accounts using granular step-by-step process. See the Guide.
-
Create the public and private keys for your user's Go Account. This generates a BIP32 master key pair that will be used to secure the wallet.
-
Use your BitGo login password to encrypt the private key (prv) that you created in the prior step. This ensures secure storage of your private key.
-
Upload to BitGo the public key (
xpub) you created in Step 1 and the encrypted private key (encryptedPrv) you created in Step 2. You receive a key ID that you must pass in the next step. -
Create a Go Account wallet for your user's child enterprise using the keychain ID from the previous step. Go Accounts are trading type wallets with a 1-of-1 multisig configuration.
-
Create a new receive address for your Go Account for a specific asset. You must specify the off-chain asset ID (e.g.,
ofctsolfor off-chain test Solana) in the onToken parameter.
// 1. Create Keys
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export SERVICE_USER_TOKEN="<SERVICE_USER_ACCESS_TOKEN>"
curl -X POST \
"http://$BITGO_EXPRESS_HOST/api/v2/ofc/keychain/local" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SERVICE_USER_TOKEN"
// 2. Encrypt Keys
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export SERVICE_USER_TOKEN="<SERVICE_USER_ACCESS_TOKEN>"
export INPUT="<PRV_KEY>"
export PASSWORD="<YOU_BITGO_LOPGIN_PASSWORD>"
curl -X POST \
"http://$BITGO_EXPRESS_HOST/api/v2/encrypt" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SERVICE_USER_TOKEN" \
-d '{
"input": "'"$INPUT"'",
"password": "'"$PASSWORD"'"
}'
// 3. Upload Keys
export SERVICE_USER_TOKEN="<SERVICE_USER_ACCESS_TOKEN>"
curl -X POST \
"https://app.bitgo-test.com/api/v2/ofc/key" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SERVICE_USER_TOKEN" \
-d '{
"encryptedPrv": "{\"iv\":\"aHbrsJVbtqlW3+8XWiy8hg==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"LxyG+VtiNVc=\",\"ct\":\"kMGJQNpRXWEq8E12vgFkLe6/1pg9pqZCZnxuXPHosQjx9jhYWe4XBCNF684m3ncwZ69qlqP5QmK8kObSoTkZP7SF2gaQugyJl+4/hgVj3Bx5QDGyiMwE/8owaJpR5CtRVkNXvXIciKL4UJ8isE9mRDfObku7VQQ=\"}",
"source": "user",
"originalPasscodeEncryptionCode": "anim",
"pub": "xpub661MyMwAqRbcFiU9xs5UzYPhgSnx4s55pSeB5FKgLAXG8xn8kdZCfbZ5fLSf8NpntDLjGcQW4oR1xiNMc21bLHbvBzPdsVy75JkRxEqtT6E"
}'
// 4. Create Go Account
export SERVICE_USER_TOKEN="<SERVICE_USER_ACCESS_TOKEN>"
export LABEL="<YOUR_WALLET_NAME>"
export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"
export KEYS="<KEY_ID>"
curl -X POST \
"https://app.bitgo-test.com/api/v2/ofc/wallet/add" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SERVICE_USER_TOKEN" \
-d '{
"label": "'"$LABEL"'",
"enterprise": "'"$ENTERPRISE_ID"'",
"type": "trading",
"m": 1,
"n": 1,
"keys": ["'"$KEYS"'"]
}'
// 5. Create Receive Address
export WALLET_ID="<YOUR_WALLET_ID>"
export SERVICE_USER_TOKEN="<SERVICE_USER_ACCESS_TOKEN>"
export ON_TOKEN="<OFF-CHAIN_ASSET_ID>"
curl -X POST \
"https://app.bitgo-test.com/api/v2/ofc/wallet/$WALLET_ID/address" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SERVICE_USER_TOKEN" \
-d '{
"onToken": "'"$ON_TOKEN"'", # For example, `ofctsol` for off-chain test Solana
}'
// 1. Create Keys
const BitGoJS = require('bitgo');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
// Set your access token here
const accessToken = '<SERVICE_USER_ACCESS_TOKEN>';
// Go Accounts are offchain wallets, denoted by ofc
const coin = 'ofc';
bitgo.authenticateWithAccessToken({ accessToken });
const key = bitgo.coin(coin).keychains().create();
console.log(JSON.stringify(key, null, 2));
// 2. Encrypt Keys
const BitGoJS = require('bitgo');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const passphrase = '<YOUR_BITGO_LOGIN_PASSWORD>';
const privateKey = '<PRV_KEY_FROM_STEP_1>';
// Encrypt the private key with your passphrase
const encryptedPrv = bitgo.encrypt({
password: passphrase,
input: privateKey
});
// 3. Upload Keys
const BitGoJS = require('bitgo');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
// Set your access token
const accessToken = '<SERVICE_USER_ACCESS_TOKEN>';
bitgo.authenticateWithAccessToken({ accessToken });
const coin = 'ofc';
const publicKey = '<PUB_KEY_FROM_STEP_1>';
const encryptedPrivateKey = '<ENCRYPTED_PRV_FROM_STEP_2>';
const enterpriseId = '<CHILD_ENTERPRISE_ID>';
const passcodeEncryptionCode = '<YOUR_ENCRYPTION_CODE>';
// Add keychain to BitGo
const keychainParams = {
pub: publicKey,
encryptedPrv: encryptedPrivateKey,
originalPasscodeEncryptionCode: passcodeEncryptionCode,
source: 'user',
enterprise: enterpriseId,
};
const addedKeychain = await bitgo.coin(coin).keychains().add(keychainParams);
console.log(JSON.stringify(addedKeychain, null, 2));
// 4. Create Go Account
const BitGoJS = require('bitgo');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
// Set your access token
const accessToken = '<SERVICE_USER_ACCESS_TOKEN>';
bitgo.authenticateWithAccessToken({ accessToken });
const coin = 'ofc';
const keychainId = '<KEYCHAIN_ID_FROM_STEP_3>';
const walletLabel = '<YOUR_WALLET_NAME>';
const enterpriseId = '<CHILD_ENTERPRISE_ID>';
// Create Go Account wallet
const walletParams = {
label: walletLabel,
m: 1,
n: 1,
keys: [keychainId],
type: 'trading', // Required for Go Accounts
enterprise: enterpriseId,
};
const walletResponse = await bitgo.coin(coin).wallets().add(walletParams);
console.log(JSON.stringify(walletResponse, null, 2));
// 5. Create Receive Address
const { BitGo } = require('bitgo');
// Fill in with actual access token
const accessToken = '<SERVICE_USER_ACCESS_TOKEN>';
// Initialize the SDK
const bitgo = new BitGo({
accessToken: accessToken,
env: 'custom',
customRootURI: 'https://app.bitgo.com',
});
// Get Go Account
const walletId = '<GO_ACCOUNT_WALLET_ID>';
const wallet = await bitgo.coin('ofc').wallets().get({ id: walletId });
// Create address for specific token
const address = await wallet.createAddress({
onToken: '<OFF-CHAIN_ASSET_ID>' // For example, 'ofctsol' for off-chain test Solana
});
console.log(JSON.stringify(address, null, 2));
// 1. Create Keys Response
{
"pub": "xpub661MyMwAqRbcEq5qQLciVPfCyCvx9KstKVp71TxujjY9Kbapv6o2YjtRAV1tfYgQZxBaN6FfFfE3CD21ZRSsd4WkqkFWSZDTiDqf49qtkh7",
"prv": "xprv9s21ZrQH143K2M1NJK5i8FiURB6TjsA2xGtWD5ZJBQ1ASoFgNZUmzwZwKC9WnyRaN2f4uAdHPdMmLbw2SsUKa6J2bWUEWihbMKcrhJSZueH"
}
// 2. Encrypt Keys Response
{
"encrypted": "{\"iv\":\"aHbrsJVbtqlW3+8XWiy8hg==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"LxyG+VtiNVc=\",\"ct\":\"kMGJQNpRXWEq8E12vgFkLe6/1pg9pqZCZnxuXPHosQjx9jhYWe4XBCNF684m3ncwZ69qlqP5QmK8kObSoTkZP7SF2gaQugyJl+4/hgVj3Bx5QDGyiMwE/8owaJpR5CtRVkNXvXIciKL4UJ8isE9mRDfObku7VQQ=\"}"
}
// 3. Upload Keys Response
{
"id": "63ee42c723f584000746d0057a2fb075",
"pub": "xpub661MyMwAqRbcFiU9xs5UzYPhgSnx4s55pSeB5FKgLAXG8xn8kdZCfbZ5fLSf8NpntDLjGcQW4oR1xiNMc21bLHbvBzPdsVy75JkRxEqtT6E",
"ethAddress": "0x098a57ddc2ce053bd73dd4d6f7f71004be082b4f",
"source": "user",
"type": "independent",
"encryptedPrv": "{\"iv\":\"aHbrsJVbtqlW3+8XWiy8hg==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"LxyG+VtiNVc=\",\"ct\":\"kMGJQNpRXWEq8E12vgFkLe6/1pg9pqZCZnxuXPHosQjx9jhYWe4XBCNF684m3ncwZ69qlqP5QmK8kObSoTkZP7SF2gaQugyJl+4/hgVj3Bx5QDGyiMwE/8owaJpR5CtRVkNXvXIciKL4UJ8isE9mRDfObku7VQQ=\"}"
}
// 4. Create Go Account Response
{
"id": "62e18ee98b38310008a830927220dfdc",
"users": [
{
"user": "62ab90e06dfda30007974f0a52a12995",
"permissions": [
"admin",
"view",
"spend"
]
}
],
"coin": "ofc",
"label": "My Go Account",
"m": 1,
"n": 1,
"keys": ["63ee42c723f584000746d0057a2fb075"],
"keySignatures": {},
"enterprise": "60e6229d19d3c400068bde7da6d41b6f",
"tags": [
"62e18ee98b38310008a830927220dfdc",
"62c5ae8174ac860007aff138a2d74df7"
],
"disableTransactionNotifications": false,
"freeze": {},
"deleted": false,
"approvalsRequired": 1,
"isCold": false,
"coinSpecific": {},
"admin": {},
"clientFlags": [],
"walletFlags": [],
"allowBackupKeySigning": false,
"recoverable": false,
"startDate": "2025-04-02T19:15:53.000Z",
"type": "trading",
"buildDefaults": {},
"customChangeKeySignatures": {},
"hasLargeNumberOfAddresses": false,
"multisigType": "onchain",
"config": {},
"balance": 0,
"confirmedBalance": 0,
"spendableBalance": 0,
"balanceString": "0",
"confirmedBalanceString": "0",
"spendableBalanceString": "0",
"pendingApprovals": []
}
// 5. Create Receive Address Response
{
"id": "67ec59c0929b08484faecc752f542d8c",
"address": "HNohgG7TsPkqBhWxxmbE1dRzuNrxSfFfdxuwxYwmMTxm",
"chain": 0,
"index": 397,
"coin": "ofc",
"token": "ofctsol",
"wallet": "62c5b1de8a0c5200071c9a603bdbadc5"
}