Web3 API is currently in Beta. To try it out, please contact our business team.
Configuration
Prerequisites
Before you begin, ensure you have the following:
- Docker
- PostgreSQL
- Wallet with funds
- thirdweb secret key
Part 1: Wallet Configuration
To use web3 API, you will need to initiate it with an admin wallet using one of the following options:
Backend Wallet
Setup a
.env
file at the root of your project’s repositorySet the following variables in your
.env
file:WALLET_PRIVATE_KEY=<YOUR_PRIVATE_KEY>
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>
# Required for AWS KMS Admin Wallet
AWS_KMS_KEY_ID=<kms_key_id>
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>
GOOGLE_KMS_CRYPTO_KEY_ID=<kms_key_id> # If created on Google Console
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:
Add the following variables to your
.env
file at the root of your repository:
# DEFAULT DOCKER
POSTGRES_HOST=host.docker.internal
POSTGRES_DATABASE_NAME=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgresTo 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:nightly
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.