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
Setup a
.env
file at the root of your project’s repositorySet 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.
Setup a managed key through AWS KMS.
- Create an IAM user with programmatic access. Follow the instructions in the AWS documentation on creating an IAM user in your AWS account.
- Enable Create, Get, and Read permissions for your KMS. Learn more about authentication and access control for AWS KMS in the AWS documentation.
- Create a KMS key by following the instructions in the AWS documentation on how to create keys.
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.
Setup a managed key through Google KMS.
- Create an encrypted key with Cloud KMS. Learn how to Create encryption keys with Cloud KMS from the Google Cloud documentation.
- Create a Service Account. Learn how to Create service accounts in the Google Cloud documentation.
- Create a key with this service account.
- Download the JSON file. The JSON file details will be used to authenticate with Google KMS.
- Add the following permissions to your service account:
Cloud KMS Admin
andCloud KMS CryptoKey Signer/Verifier
Setup a
.env
file at the root of your repositorySet 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:
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
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
infoFor different versions, please see our Docker Hub page.
To authenticate, open
localhost:3005
in your browser.Select the
Authorize
option on the dashboard.Pass in your corresponding secret key created from the thirdweb dashboard and select Authorize.
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.