Deploy a ThirdWeb NFT Marketplace using Streambird Platform Wallet
To build an application that uses Streambird API for deploying a ThirdWeb NFT marketplace, developers will need to follow a series of steps. Below is a tutorial that outlines these steps and provides examples of code to help developers get started.
Step 1: Register for a Streambird API Key
To use Streambird API, developers need to register for an API key. To do this, visit the Streambird API website (https://app.streambird.io/) and sign up for an account. After signing up, developers will be able to access the API key on their dashboard, and use the API key to authorize requests.
Step 2: Create or Get a wallet
Create a wallet if you do not have using the following cURL script or use an existing wallet:
- Replace
$API_KEY
with your Streambird API Key. - Replace
$USER_ID
with your user ID. - Run the following cURL command in your terminal:
Step 3: Install Required Dependencies
To build the application, developers will need to install the following dependencies:
ethers
: A JavaScript library that provides a simple interface to interact with Ethereum nodes and smart contracts.
node-fetch-commonjs: A light-weight module that brings the Fetch API to Node.js.
To install these dependencies, use the following command:
Step 4: Import the required dependencies
Add the following lines to the top of your JavaScript file to import the required dependencies:
Step 5: Set up the provider
Create a new instance of ethers.providers.JsonRpcProvider using the Goerli test network’s RPC URL. You can use Infura as the provider to access the Goerli network.
- Replace the
ALCHEMY_API_KEY
with your Alchemy API Key.
Step 6: Define the gas price function
Create an async function called getGasPrice
that calculates the gas price for the transaction. The function uses the getGasPrice
method to retrieve the current gas price, formats the price to ether, multiplies it by the given multiplier, and then converts it back to wei.
Step 7: Define the send transaction function
Create an async function called sendRawTransaction
that sends a raw transaction to the Goerli network via the Ethereum JSON-RPC endpoint. This function is used to deploy the Thirdweb marketplace. The function does the following:
- Defines the contract address and ABI.
- Sets the implementation, data, and salt for the smart contract.
- Encodes the function data for the
deployProxyByImplementation
function. - Retrieves the transaction count for the fromAddress account.
- Defines the gas limit and the chain ID.
- Defines the transaction object with the to, data, gas price, gas limit, chain ID, and nonce.
- Calls the
fetchSignedTx
function to sign the transaction. - Sends the signed transaction to the network and waits for the transaction to be confirmed.
Step 8: Define the fetchSignedTx
function
The fetchSignedTx
function takes a transaction object as input, signs the transaction using a Streambird Wallet API, and returns the signed transaction object. You can find more information about the WalletSignTransaction endpoint in the Streambird API.
- Replace
$API_KEY
with your Streambird API Key. - Change the
$WALLET_ID
variable to match the ID of the wallet from which you want to sign the transaction. - Modify the signedTxUrl variable to match the endpoint where you want to send the signed transaction.
- Adjust the headers object to match the authorization credentials required to access the endpoint.
- Update the body of the POST request to include any additional data required by the endpoint to successfully sign the transaction.
Conclusion:
In conclusion, deploying a ThirdWeb marketplace using the Streambird API requires a few key steps. First, developers must create an account with Streambird and generate an API key. They must then install the necessary dependencies and configure their application to use the Streambird API. Once this is done, developers can use the API to perform various functions, such as creating wallets, signing transactions, and querying blockchain data. By following the steps outlined in this tutorial, developers can get up and running with the Streambird API and begin building their own decentralized marketplaces.
While this tutorial focused on deploying a ThirdWeb marketplace using the Streambird Wallet API, the same general steps can be used to launch any smart contract. Developers can follow these steps to deploy their own smart contracts and integrate them into their applications. By leveraging the Streambird API, developers can simplify the process of signing transactions and interacting with the Ethereum network, allowing them to focus on building their applications and bringing their ideas to life. With the power of smart contracts and the growing ecosystem of tools and services available to developers, the possibilities are endless.
Source code on Github
Additional notes and materials
You will also need an ABI file for the Thirdweb marketplace called proxy.json
.