Accounts

Accounts are a core part of Openfort — the very reason Openfort exists is so you can have secure accounts for your players. On this page, we'll dive into the different account endpoints you can use to manage accounts programmatically. We'll look at how to query, create and update accounts.

The Account object

Attributes

  • Name
    id
    Type
    string
    Description

    Unique identifier for the account. It starts with acc_.

  • Name
    created_at
    Type
    timestamp
    Description

    Timestamp with timezone of when the account was created.

  • Name
    address
    Type
    string
    Description

    A string representing the account's address.

  • Name
    custodial
    Type
    boolean
    Description

    Indicates whether the player has full custody of the account (is the owner of the account).

  • Name
    transaction_intents
    Type
    array of hashes
    Description

    A list of accounts associated with the player. Refer to TransactionIntents object.

More attributes


GET/v1/accounts

List accounts

This endpoint allows you to retrieve a paginated list of all accounts of a player. By default, a maximum of ten accounts are shown per page.

Request

GET
/v1/accounts
  curl -G https://api.openfort.xyz/v1/accounts \
  -H "Authorization: Bearer $YOUR_SECRET_KEY" \
  -d player="pla_42510499-0739-5813-bcf6-850bb91e935b"

Response

  {
    "object": "list",
    "url": "/v1/accounts",
    "data": [
        {
            "id": "acc_c502d628-5bb3-42f2-b8d5-62ba46717f3a",
            "created_at": "2023-04-04T10:23:04.571Z",
            "address": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa",
            "chain_id": 5,
            "deployed": false
        },
        {
            "id": "acc_3e044c81-1002-409f-9423-522fbecfc1f4",
            //...
        }
    ]
  }

POST/v1/accounts/

Create an account

This endpoint allows you to add a new account to your account list for a player in Openfort.

Required attributes

  • Name
    player
    Type
    string
    Description

    The ID of the player associated with the account.

  • Name
    chain_id
    Type
    int
    Description

    The ID of the blockchain network.

Request

POST
/v1/accounts
  curl https://api.openfort.xyz/v1/accounts \
  -H "Authorization: Bearer $YOUR_SECRET_KEY" \
  -d player="pla_42510499-0739-5813-bcf6-850bb91e935b" \
  -d chain_id=5

Response

  {
    "id": "acc_c502d628-5bb3-42f2-b8d5-62ba46717f3a",
    "object": "account",
    "created_at": "2023-04-04T10:23:04.571Z",
    "chain_id": 5,
    "deployed": false,
    "address": "0x8C5cedA46A26214A52A9D7BF036Ad2F6255BdBEa",
    ...
  }

POST/v1/accounts/:id/transfer-ownership

Transfer ownership

This endpoint allows you to perform an update on the owner of the account. To perfom an update on the owner of an account, first you must provide a new owner address. Then, the new owner must accept to take ownership by calling acceptOwnership() in the smart contract account.

Required attributes

  • Name
    new_owner_address
    Type
    string
    Description

    A string representing the account's new owner address.

Optional attributes

  • Name
    policy
    Type
    string
    Description

    The unique identifier for the gas policy to be used for this transaction. It starts with pol_.

Request

POST
/v1/accounts/:id/transfer-ownership
  curl https://api.openfort.xyz/v1/accounts/acc_.../transfer-ownership \
  -H "Authorization: Bearer $YOUR_SECRET_KEY" \
  -d new_owner_address="0xe781...0185" \
  -d policy="pol_..."

Response

  {
    "id": "tin_...",
    "created_at": "2023-04-25T09:12:22.214Z",
    "user_operation_hash": "0x4165...d18f",
    "user_operation": {
        "sender": "0xc017dBca3F51E0655AbF1303B6054Cc4eed8A908",
        "nonce": 0,
        ...
    },
    "chain_id": 80001,
    "updated_at": "2023-04-25T09:12:22.214Z",
    "policy": "pol_...",
    "account": "acc_...",
    "next_action": null,
    "player": "pla_...",
    "response": {
        "created_at": "2023-04-25T09:12:40.941Z",
        ...
    },
    "transactions": [
        ...
    ],
    "object": "transaction_intent"
  }

GET/v1/accounts/:id

Retrieve an account

This endpoint allows you to retrieve a account by providing their Openfort id. Refer to the Account object to see which properties are included with account objects. Refer to the transactionIntents object to see which properties are included with transaction objects.

Request

GET
/v1/accounts/:id
  curl -G https://api.openfort.xyz/v1/accounts/acc_... \
  -H "Authorization: Bearer $YOUR_SECRET_KEY"

Response

  {
  "id": "acc_...",
  "object": "account",
  "created_at": "2023-04-03T12:37:46.580Z",
  "chain_id": 5,
  "deployed": true,
  "address": "0xe781...0185"
}