Migrating from Engine v2 to v3
Learn how to migrate your applications from Engine v2 to Engine v3. We'll cover common operations and highlight the differences in API requests and authentication.
Migrating Wallets
If you'd like to migrate your wallets from v2 to v3 to also be secured by Vault or thirdweb's key management service, please contact us for assistance.
Migrating your contract write operations from v2 to v3 involves changes to the endpoint, authentication mechanism, and request payload structure.
The v2 approach used your dedicated engine url, with a specific endpoint for each chain and contract and backend wallet address in the header.
The v3 approach uses a generic POST endpoint, with authentication via secret key and vault access token. Contract, chain, and execution details are now part of a structured JSON payload.
- API Endpoint: The endpoint has changed from a specific path per chain and contract (
<engine_url>/contract/<chain>/<contract_address>/write
) to a general endpoint (https://engine.thirdweb.com/v1/write/contract
). - Authentication:
- V2 used an
Authorization: Bearer <access_token>
header for general API access and anx-backend-wallet-address
header to specify the sender. - V3 uses an
x-secret-key
header (your project's secret key, found in your thirdweb dashboard) for authentication. Your backend wallet is managed by thirdweb Vault, anx-vault-access-token
header is required for all write operations.
- V2 used an
- Request Structure:
- Sender & Chain: In V2, the sender wallet was a header, and the chain was part of the URL. In V3, these are specified in the request body within an
executionOptions
object:from
for the sender wallet address andchainId
for the target chain. - Contract Call: V2 took
functionName
andargs
directly in the body. V3 uses aparams
array in the request body. Each element in this array is an object defining the targetcontractAddress
, the partial or fullmethod
signature (e.g.,"function mintTo(address to, uint256 amount)"
), and theparams
(arguments) for that method.
- Sender & Chain: In V2, the sender wallet was a header, and the chain was part of the URL. In V3, these are specified in the request body within an
- Function Specification: While V3 supports using just the method name (e.g., "transferFrom") in the
method
field, providing the full function signature (e.g., "function transferFrom(address from, address to, uint256 amount)") is highly recommended for optimal performance as it avoids an ABI lookup. V2 only required thefunctionName
.
Querying transaction status has also been updated, moving from a direct ID lookup via GET to a POST request with a filter-based search.
In v2, transaction status was fetched using a GET request with the queue_id
in the URL.
V3 uses a search endpoint with a POST request, where transaction identifiers are passed in the request body using filters.
- API Endpoint & Method: The V2
GET
endpoint (<engine_url>/transaction/status/<queue_id>
) is replaced by a V3POST
endpoint (https://engine.thirdweb.com/v1/transactions/search
). - Authentication:
- V2 used an
Authorization: Bearer <access_token>
header. - V3 uses an
x-secret-key
header (your project's secret key).
- V2 used an
- Querying Transaction Status:
- In V2, the
queue_id
was passed directly in the URL path. - In V3, you send a
POST
request with a JSON body containing afilters
array. To find a specific transaction, you filter by itsid
(the equivalent of V2'squeue_id
). This filter-based approach is more flexible for querying transactions based on various criteria.
- In V2, the
Reading data from a smart contract has also been updated in v3, shifting from URL-based parameters to a structured JSON payload over POST.
In v2, contract reads were GET requests. The chain, contract address, function name, and arguments were specified in the URL path and query parameters.
V3 uses a POST request to a dedicated read endpoint. All parameters, including chain, contract details, method signature, and arguments, are provided in the JSON body.
- API Endpoint & Method:
- V2 used a
GET
request to<engine_url>/contract/<chain>/<contract_address>/read
with function details as query parameters. - V3 uses a
POST
request to the generic endpointhttps://engine.thirdweb.com/v1/read/contract
.
- V2 used a
- Authentication:
- V2 used an
Authorization: Bearer <access_token>
header. - V3 uses an
x-secret-key: <your-project-secret-key>
header.
- V2 used an
- Request Structure:
- In V2, the chain and contract address were part of the URL path, and the function name (
functionName
) and its arguments (args
) were URL query parameters. - In V3, the request body is a JSON object. It includes a
params
array (where each object specifiescontractAddress
, the partial or fullmethod
signature, and itsparams
) and areadOptions
object to specify thechainId
.
- In V2, the chain and contract address were part of the URL path, and the function name (
- Function Specification: Similar to contract writes, while V3 supports using just the method name (e.g., "balanceOf") in the
method
field, providing the full function signature (e.g., "function balanceOf(address account) returns (uint256)") is highly recommended for optimal performance as it avoids an ABI lookup. V2 primarily used just the function name in thefunctionName
query parameter.
Engine v2 has a large number of endpoints to do specific contract calls, like mintTo, claimTo, etc.
Engine v3 does not have these endpoints yet, but they are coming soon. In the meantime, if your backend is written in typescript, we recommend using the thirdweb SDK to do these operations:
The entire thirdweb SDK is available to use with engine v3 in this manner using the Engine
namespace. Check the thirdweb SDK docs for all available functions.