Skip to main content

Setting up Development Environment

This tutorial will guide you through setting up your development environment and creating a simple "Hello World" serverless function.

Prerequisites​

The following tools need to be installed:

Installation​

Begin by cloning the Oyster Serverless development tools repository and navigating to the repository directory:

git clone https://github.com/marlinprotocol/oyster-serverless-devtools.git
cd oyster-serverless-devtools/local-tester

Next, pull the tester Docker image.

docker pull veegee33/tester

Finally, make the tester script executable:

chmod +x mock_serverless.sh

Create a serverless function​

Let's create a simple function to verify your setup.

Create a new file named hello.js in the local-tester directory with the following content:

addEventListener("fetch", event => {
event.respondWith(new Response("Hello World"));
});

Test the serverless function​

Run a local test server:

./mock_serverless.sh 8090 hello.js

Next, open a new terminal and run:

curl -X POST http://localhost:8090

You should see the message "Hello World".

Troubleshooting​

Common issues and solutions:

  • Port already in use: If port 8090 is already in use, try a different port number
  • Permission denied: Ensure Docker is properly installed and your user has the necessary permissions

Now that you've successfully tested your serverless function locally, you're ready to deploy it to the blockchain!