Skip to main content
info

Web3 API is currently in Open Beta and requires self-hosting. If you need a managed version, please contact us.

Configuration

Prerequisites

Before you begin, ensure you have the following:

  • Docker
  • PostgreSQL

Part 1: Wallet Configuration

To use web3 API, you will need to initiate it with a backend wallet using one of the following options:

Secret Key

  1. Setup a .env file at the root of your project’s repository

  2. Set the following variables in your .env file:

    POSTGRES_CONNECTION_URL=<YOUR_CONNECTION_URL>
    THIRDWEB_SDK_SECRET_KEY=<YOUR_SECRET_KEY>

AWS KMS

Web3-API supports AWS KMS for signing & sending transactions over any EVM chain.

  1. Setup a managed key through AWS KMS.

    1. Create an IAM user with programmatic access. Follow the instructions in the AWS documentation on creating an IAM user in your AWS account.
    2. Enable Create, Get, and Read permissions for your KMS. Learn more about authentication and access control for AWS KMS in the AWS documentation.
    3. Create a KMS key by following the instructions in the AWS documentation on how to create keys.
  2. Setup a .env file at the root of your repository and set the following variables in this file.

    # Required for AWS Auth
    AWS_ACCESS_KEY_ID=<aws_access_key_id>
    AWS_SECRET_ACCESS_KEY=<aws_secret_access_key>
    AWS_REGION=<aws_region>

Google KMS

Web3-API supports Google KMS for signing & sending transactions over any EVM chain.

  1. Setup a managed key through Google KMS.

    1. Create an encrypted key with Cloud KMS. Learn how to Create encryption keys with Cloud KMS from the Google Cloud documentation.
    2. Create a Service Account. Learn how to Create service accounts in the Google Cloud documentation.
    3. Create a key with this service account.
    4. Download the JSON file. The JSON file details will be used to authenticate with Google KMS.
    5. Add the following permissions to your service account: Cloud KMS Admin and Cloud KMS CryptoKey Signer/Verifier
  2. Setup a .env file at the root of your repository

  3. Set the following variables in your .env file:

    # Required for Google Auth
    GOOGLE_APPLICATION_CREDENTIAL_EMAIL=<client_email_from_download_service_account_json>
    GOOGLE_APPLICATION_CREDENTIAL_PRIVATE_KEY=<private_key_from_download_service_account_json>

    # Required for Google KMS
    GOOGLE_APPLICATION_PROJECT_ID=<google_project_id>
    GOOGLE_KMS_KEY_RING_ID=<key_ring_id>
    GOOGLE_KMS_LOCATION_ID=<location_of_key_ring>

Part 2: Server Configuration

While in beta, Web3 API only offers self-hosted options. To use Web3 API, you will need to host your own server using a containerization platform such as Docker or Kubernetes.

Configure Server Using Docker

To host your own server with Docker:

  1. Install Docker

  2. To obtain the Postgres Docker Image, navigate to the root of your project and run the following command in your command line:

    docker run --env-file ./.env -p 5432:5432 --name my-local-postgres -d postgres
  3. Afterwards, to get the Web3 API Docker Image, navigate to the root of your project and run the following command in your command line:

    docker run --env-file ./.env -p 3005:3005 --name web3-api thirdweb/web3-api:latest
    info

    For different versions, please see our Docker Hub page.

  4. To authenticate, open localhost:3005 in your browser.

  5. Select the Authorize option on the dashboard.

    Screenshot of how to authorize via Swagger

  6. Pass in your corresponding secret key created from the thirdweb dashboard and select Authorize.

    Screenshot of passing in Bearer auth field

  7. You are now ready to begin developing using APIs. To see a demonstration of endpoints, please visit the Get Started tutorial.

Authorization Header

All Requests need to have Authorization header with the value of Bearer <YOUR_THIRDWEB_SDK_SECRET_KEY> from the .env file.

For specific examples of implementation, follow along with our Get Started tutorial.