Skip to content

Latest commit

 

History

History
119 lines (66 loc) · 8.15 KB

draft-661640146c00e013ce8c5cf8.md

File metadata and controls

119 lines (66 loc) · 8.15 KB
title slug cover
How to Deploy a Self-hosted thirdweb Engine On Railway In Less Than 3 Minutes
how-to-deploy-a-self-hosted-thirdweb-engine-on-railway-in-less-than-3-minutes

Are you looking for a production-grade HTTP server to interact with any smart contract on any EVM? That's the thirdweb Engine!

Engine is a backend HTTP server that reads, writes, and deploys contracts on a large scale. It allows you to create and interact with backend developer wallets, supporting high throughput with automatic nonce and gas management. Think of this as your rail transport vehicle or train Engine for your Railway. 🚂

Railway is a deployment platform created to simplify the software development lifecycle. It starts with instant deployments and easy scaling and includes CI/CD integrations and built-in observability. Let's say this is the Railway track for your train Engine. 🛤️

In this tutorial blog, you'll learn how to deploy your self-hosted thirdweb Engine on the Railway platform in less than 3 minutes using our community-contributed Railway template. This is the official community Railway template maintained by the thirdweb community team.

Without further ado, let's deploy your Engine to its Railway. 🚂🛤️ (you get it?)

Are you looking for a managed thirdweb Engine? Try Cloud-Hosted!

Requirements

Steps

  1. Go to your Railway dashboard and create a "New Project."

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713272787740/636b8689-6594-47b4-848b-33ea57c25764.png align="center")

  2. On the new project page, search for "thirdweb" or "thirdweb Engine," and you will find the template we created.

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713272932738/d0ae83f5-de52-45ab-bb3d-a531210ddee0.png align="center")

  3. You will be redirected to the deploy page. First, click the "Configure" button for the Postgres service. Lastly, save the configuration and return to this page.

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713341464873/2a451398-f164-445f-ad1f-160a86faee21.png align="center")

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713341688018/43f480be-f8e8-41aa-90cf-5e0b979e5912.png align="center")

  4. Let's set up the thirdweb Engine service. Enter your wallet address into the ADMIN_WALLET_ADDRESS field, and then enter your "thirdweb API secret key" into the THIRDWEB_API_SECRET_KEY key input field. After that, save the configuration and return to the template deployment page.

  5. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713341935145/aa0322fa-0235-4734-a475-e294fd187a5f.png align="center")

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713342418431/b974c06a-3ce2-4d86-b9ff-1b66e445d125.png align="center")

    All you have to do is click the "Deploy" button and wait.

  6. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713342795793/b65e32eb-59eb-4fe4-8c9c-3539d4509d7c.png align="center")

    In less than 3 minutes, your thirdweb Engine will be ready for use. Go to your Engine service > Settings > Networking > Public Networking to find your endpoint URL.

  7. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713343606568/2d1e63a8-6cb4-4855-80cc-625624219585.png align="center")

    Open this endpoint URL in your browser, and you'll receive an API message response. This indicates a successful Engine installation. Be sure to save this; you will need it to import into your thirdweb Engine dashboard.

  8. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713343998368/5d6acc5f-ae45-44c9-883c-e6128b0e3594.png align="center")

  9. Now, let's import your endpoint URL to your thirdweb dashboard. Navigate to your Engine dashboard and select the "Import" button.

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713344362888/169c12c9-c95f-411c-bb5e-454c79b90223.png align="center")

  10. Name your self-hosted thirdweb Engine, enter the endpoint URL from your Railway project, and click the import button. Follow the example provided below.

  11. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713344509842/2c6d53d1-e130-4abf-a59f-b30dfc347e41.png align="center")

    After you import it, it should look like this. Go ahead and view and manage your self-hosted thirdweb Engine from your account dashboard.

  12. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713344826533/fcdb8c51-1caa-4de0-a731-e0f6cb1b1f9a.png align="center")

    Don't forget to create your backend wallet to execute write transactions and generate your access token. This will allow you to interact with your Engine API.

  13. ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713345091101/fdf637fc-060d-4da6-9b16-f9a9cccf47a3.png align="center")

    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713345122537/8b9e406c-f512-4b60-8c84-0fe4c1f90ad6.png align="center")

    That's it! 🚀

Testing

In this section, let's test your engine to see if it works. The simplest method is to make a direct request using curl in your terminal. Just replace the <xxxx> with your Railway endpoint URL and provide your access token from your thirdweb Engine dashboard.

We will send a GET request to read the contract information for name on the base-sepolia-testnet chain. Let's use 0xD1042CC90244beeE8E30e1655f1935C3e8BFB86a as our test contract address.

curl -X 'GET' \
  'https://engine-production-<xxxx>.up.railway.app/contract/base-sepolia-testnet/0xD1042CC90244beeE8E30e1655f1935C3e8BFB86a/read?functionName=name' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <your access token here>'

Copy and paste this command into your terminal and press enter. It should return a response with the name of our test contract. The name should be Mata NFT.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713346930114/c961ecdd-1bff-4ec3-8e92-eeded64b9279.png align="center")

You can also use the Insomnia software to test your Engine. We performed a similar request using its graphical user interface (GUI). Enter your access token in the Bearer field as your authentication method, and then input your GET request URL. After that, click "Send." You should receive a 200 response code and the test contract's name.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713346646308/2ca884fa-1717-44c4-a993-0cbfb510469f.png align="center")

This is it. If you see a similar result, you're good to go! 🚂🛤️

Update

You need to update the version manually from the Railway dashboard. To do this, navigate to your Engine service and redeploy the source.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713350921150/f5811d28-71c5-4c53-a7cc-efcad332d753.png align="center")

Are you looking for an effortless version update? Try Cloud-Hosted!

Enjoy, and keep building! 🫶