The Oyster Serverless CLI is a command-line tool that simplifies the development and deployment of serverless functions on the Oyster Severless platform. It supports local testing, Job deployment, and recurring job scheduling, enabling developers to efficiently build and manage secure, scalable serverless applications.
To build from source, ensure you have the following installed:
- Rust: The programming language required for building the project.
- Cargo: The Rust package manager and build system.
git clone https://github.com/marlinprotocol/oyster-monorepo.git
cd cli/oyster-serverless
cargo build --releaseSupports both Linux and MacOS builds.
# linux amd64
nix build .#packages.x86_64-linux.default.cli.oyster-serverless.default
# linux arm64
nix build .#packages.aarch64-linux.default.cli.oyster-serverless.default
# macOS arm64 (Apple Silicon)
nix build .#packages.aarch64-darwin.default.cli.oyster-serverless.default
oyster-serverless doctor
Checks if docker is installed
Below are the steps for developing and testing your oyster-serverless functions.
-
Create the project
oyster-serverless new
Arguments:
name: Name of the project
Note: This command creates a new project with the provided name and gives users the option to select a template or provide a raw GitHub code link for their Workerd JavaScript code.
-
Navigate into the project directory
cd first-example-project -
Modify the JS file as needed by following the workerd guideline.
-
Test the setup locally by running the following command:
⚠️ Note: Depending on your Docker setup, you might need to run this command with root privileges.oyster-serverless dev
If you encounter issues, try running it with
sudo:sudo oyster-serverless dev
Arguments:
input-file(Optional) : Input file path for the workerd program.
Deploy JavaScript code to the Oyster Serverless platform.
oyster-serverless deployArguments:
wallet-private-key: Private key for transactions.contract-address(optional): Overrides the default serverless contract address.minified(optional): Minify the JS file.
Note : Defaults to worker.js created by the new project command
Output:
- Transaction hash of the saved code.
Create a serverless job on the platform.
oyster-serverless job createArguments:
wallet-private-key: Private key for transactions.callback-contract-address: Any address.env(optional): Execution environment (defaults to 1).refund-account(optional): Address to receive compensation if the job fails (defaults to sender's address).code-hash: Transaction hash of the deployed JS code.input-file(optional): Path for worker input fileuser-timeout: Maximum time allowed for executors to complete the computation.max-gas-price(optional): Multiplier (e.g: 1.5,2,2.5).callback-gas-limit: Gas limit for the callback function.
Sample command:
oyster-serverless job create --wallet-private-key *** --code-hash 0x6a7478d2ad9c041bef6f0d975ad6d787c42609ec4f700afcba1679eb18ac08d1 --input-file input.json --user-timeout 5000 --callback-contract-address 0x67a0cc925b787eCdb470315E4e7DBc107370A8f4 --callback-gas-limit 1000
Fetch the response of a serverless job.
oyster-serverless job fetch-responseArguments:
job-transaction-hash: Transaction hash returned by the create job command.
Cancel a serverless job.
⚠️ Note: Need to wait for relay overall timeout after the job is created.
oyster-serverless job cancelArguments:
wallet-private-key: Private key for transactions.job-transaction-hash: Transaction hash returned by the create job command.
Retrieve a user's jobs based on their wallet address.
oyster-serverless job listArguments:
address: Address to list jobs forstatus(optional): Status of jobs to list [default: pending] [possible values: success, pending, failed, cancelled]
Create a recurring serverless job (subscription).
oyster-serverless subscription createArguments:
wallet-private-key: Private key for transactions.env(optional): Execution environment (defaults to 1).callback-contract-address: Any address.start-timestamp(optional): Timestamp for starting the sub.code-hash: Transaction hash of the deployed JS code.input-file(optional): Path for worker input fileperiodic-gap(optional): Interval at which the function will be executed (e.g., every 30 seconds).termination-timestamp(optional): Timestamp to terminate the subscription.user-timeout: Time limit for executors.max-gas-price(optional): Multiplier (e.g: 1.5,2,2.5).callback-gas-limit: Gas limit for the callback function.refund-account(optional): Address to receive compensation if the job fails (defaults to sender's address).
Sample command:
oyster-serverless subscription create --wallet-private-key **** --code-hash 0x6a7478d2ad9c041bef6f0d975ad6d787c42609ec4f700afcba1679eb18ac08d1 --input-file input.json --user-timeout 5000 --callback-contract-address 0x67a0cc925b787eCdb470315E4e7DBc107370A8f4 --callback-gas-limit 1000
Note: If not provided as arguments, the
start-timestamp,termination-timestamp, andperiodic-gapvalues can be entered through interactive prompts.
Fetch the response of a serverless subscription.
oyster-serverless subscription fetch-responseArguments:
subscription-transaction-hash: Transaction hash returned by the create subscription command.stream: If set, listen for job responses until subscription is terminated. Else, get the responses received till the current time.
Update the termination timestamp for the serverless subscription.
oyster-serverless updateArguments:
wallet-private-key: Private key for transactions.subscription-transaction-hash: Transaction hash returned by the create subscription command.termination-timestamp- Timestamp for terminating the job.
Terminate a subscription
oyster-serverless terminateArguments:
wallet-private-key: Private key for transactions.subscription-transaction-hash: Transaction hash returned by the create subscription command.
Refund deposits for a terminated subscription
oyster-serverless refund-depositsArguments:
wallet-private-key: Private key for transactions.subscription-transaction-hash: Transaction hash returned by the create subscription command.
Retrieve and display all subscriptions associated with a specific wallet address.
oyster-serverless subscription listArguments:
address: Wallet address to list subscriptions for (required)completed(optional): Boolean flag to filter subscriptions- If provided: Shows completed subscriptions (terminated and either refunded or refundable)
- If not provided: Shows active subscriptions (default)