Wallets API

Wallet is the top-level object that represents a wallet and it contains all the other objects that are related to a wallet. A Wallet currently can exist on a network.

Create

You can create wallets using the following GraphQL mutation with the CreateWalletInput input. It has multiple required inputs, including the orgId, name, networkId, mainKeyId, and backupKeyId. The mainKeyId and backupKeyId are the keyId of the main and backup keys that you should have created using the CreateKey mutation.

MutationGraphQL
mutation CreateWallet($input: CreateWalletInput!) {
  createWallet(input: $input) {
    walletId
    organizationNetworkId
    organizationNetwork {
      network {
        protocolName
        networkName
      }
    }
    name
    status
    mainAddress
  }
}
VariablesJSON
{
  "variables": {
    "input": {
      "orgId": "868202983161",
      "description": "API-created Levain Wallet powered by SimpleMultiSig",
      "type": "EvmContractSimpleMultiSig",
      "name": "API-created Levain Wallet 1",
      "mainKey": {
        "keyId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
        "passwordRecoveryKeyId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
        "encryptedPrivateKey": "..."
      },
      "backupKey": {
        "keyId": "01234abc-e382-4d2f-bcea-0b789c00c18b"
      }
    }
  }
}
ResponseJSON
{
  "data": {
    "createWallet": {
      "walletId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
      "organizationNetworkId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
      "organizationNetwork": {
        "network": {
          "protocolName": "Ethereum",
          "networkName": "Goerli Testnet"
        }
      },
      "name": "API-created Levain Wallet 1",
      "status": "ACTIVE",
      "mainAddress": "0x734251c89a207d743f483fdfc56c15a8637524f2"
    }
  }
}

Retrieve

There are multiple ways to retrieve wallet details. The first is to use the wallet query. It only requires the walletId as an input and returns the Wallet object.

QueryGraphQL
query Wallet($walletId: ID!) {
  wallet(walletId: $walletId) {
    walletId
    organizationNetworkId
    organizationNetwork {
      network {
        protocolName
        networkName
      }
    }
    name
    status
    mainAddress
  }
}
VariablesJSON
{
  "variables": {
    "walletId": "01234abc-e382-4d2f-bcea-0b789c00c18b"
  }
}
ResponseJSON
{
  "data": {
    "createWallet": {
      "walletId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
      "organizationNetworkId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
      "organizationNetwork": {
        "network": {
          "protocolName": "Ethereum",
          "networkName": "Goerli Testnet"
        }
      },
      "name": "API-created Levain Wallet 1",
      "status": "ACTIVE",
      "mainAddress": "0x734251c89a207d743f483fdfc56c15a8637524f2"
    }
  }
}

Update

You can update wallets using the following GraphQL mutation with the UpdateWalletInput input, though only wallet name and description can be updated.

You cannot change the wallet type or the network it is on, and you cannot change the main address due to the immutable nature of the blockchain. At this point, you also cannot change the main or backup keys.

MutationGraphQL
mutation UpdateWallet($input: UpdateWalletInput!) {
  updateWallet(input: $input)
}
VariablesJSON
{
  "variables": {
    "input": {
      "walletId": "01234abc-e382-4d2f-bcea-0b789c00c18b",
      "name": "My Wallet",
      "description": "My Wallet Description"
    }
  }
}
ResponseJSON
{
  "data": {
    "updateWallet": true
  }
}

Delete

Wallets can never be deleted, they should only be deactivated. At this point, Levain does not support deactivating wallets. If you need to deactivate a wallet, please contact your account manager or email the Levain Product Team.