Engine is currently in Open Beta and requires self-hosting. If you need a managed version, please contact us.
Get Started
Once you have configured your self-hosted server, you can begin development with the Engine.
This guide will provide a few examples of how you can use the Engine:
Get Balance
To quickly demonstrate how to use Engine in your application, let's create a quick JavaScript script that fetches your wallet's balance on a specific network using the /wallet/{network}/getBalance endpoint.
Create a
getBalance.jsat the root of your project’s directoryAt the top of your file, let’s create a variable to store our network to pass into our path parameter.
const network = "mumbai";Configure your HTTP GET request
const options = {
method: "GET",
headers: {
accept: "application/json",
"content-type": "application/json",
Authorization: `Bearer ${process.env.THIRDWEB_SDK_SECRET_KEY}`,
},
};Now we can use the
fetch()function to make an HTTP GET request to ourwallet/${network}/getBalanceendpoint and display the result to our console.fetch(`http://localhost:3005/wallet/${network}/getBalance}`, options)
.then((response) => response.json())
.then((response) => console.log(response.result.displayValue))
.catch((err) => console.error(err));Run your script in the command using
node getBalance.jsIn the terminal, you will see the amount of Matic you have in your wallet returned.
Deploy Contract
As an example for a POST method, let's modify our script to deploy an ERC20 Contract using /deployer/{network}/prebuilts/token
Create a
deployToken.jsat the root of your project’s directoryAt the top of your file, let’s create a variable to store our network to pass into our path parameter.
const network = "mumbai";Configure your HTTP POST request body. Modify the
primary_sale_recipientto your address or the address you want to receive initial funds.const options = {
method: "GET",
headers: {
accept: "application/json",
"content-type": "application/json",
Authorization: `Bearer ${<thirdweb_secret_key>}`,
"x-wallet-address": ${process.env.WALLET_ADDRESS}`
},
body: JSON.stringify({
name: "HelloWorldCoin",
description: "A coin to demonstrate how to use Engine",
symbol: "HELLO",
primary_sale_recipient: "0x0000000000000000000000000000000000000000",
}),
};Now we can use the
fetch()function to make an HTTP GET request to our/deployer/{network}/prebuilts/tokenand return the URL for the deployed contract on the dashboard.fetch(`http://localhost:3005/deployer/${network}/prebuilts/token`, options)
.then((response) => response.json())
.then((response) => console.log(`https://thirdweb.com/${network}/${response.result.deployedAddress}`)
.catch((err) => console.error(err));Run your script in the command using
node deployToken.jsTo find your contract, redirect from the link returned in the command line.