This repository contains helper tools for developers who wish to develop applications using Oyster Serverless
First, clone the oyster-serverless-devtools
github repository and change directory to local_tester
.
git clone https://github.com/marlinprotocol/oyster-serverless-devtools.git && cd oyster-serverless-devtools/local_tester
Pull docker image for local test server
docker pull veegee33/tester
Run local test server
chmod +x mock_serverless.sh
sudo ./mock_serverless.sh 8090 <path-to-js-file>
Perform the test call
curl http://0:8090/ -v -d '{"num": 60000}'
Setup the environment:
git clone https://github.com/marlinprotocol/oyster-serverless-devtools.git && cd oyster-serverless-devtools/user_contract_builder
npm install
Check the environment by running npx hardhat
.
$ npx hardhat
Hardhat version 2.22.1
Usage: hardhat [GLOBAL OPTIONS] [SCOPE] <TASK> [TASK OPTIONS]
...
Check the sample contract at contracts/UserSample.sol
. This can be used as base for developing new smart contract to utilize Oyster Serverless. For Subscription example, check contracts/SubsUser.sol
.
To compile contracts:
npx hardhat compile
Deployment script can be found at script/deploy/UserSample.ts
. In the script, replace the values of the relayAddress
and usdcToken
variables with the addresses of the already deployed Relay and USDC contracts, respectively. Here are the steps to deploy the contract on Arbitrum Sepolia Testnet.
Create an account using metamask wallet. Then, select Arbitrum Sepolia as network on Metamask extension. Get some Arbitrum Sepolia ETHs using faucet. Make sure that account private key is accessible.
Next, follow this guide to generate an Arbiscan API Key.
Now, create an user_contract_builder/.env
file with following content. Fill the place holder with above generated value.
ARBITRUM_SEPOLIA_DEPLOYER_KEY=<deployer-account-private-key>
ARBISCAN_API_KEY=<arbiscan-api-key>
At the end, run following command to deploy contract on Arbitrum Sepolia Testnet. This will print the deployed contract address.
npx hardhat run script/deploy/UserSample.ts --network arbs
Similar steps can also be followed for other chains with relevant configs (check hardhat.config.ts
).
For the subscription example, use the script at script/deploy/SubsUser.ts
, following the same step as above. In the script, replace the values of the relaySubscriptionsAddress
and usdcToken
variables with the addresses of the already deployed Subscription Relay and USDC contracts, respectively.
Hardhat provides contract verification, allowing users to interact directly with contracts on Arbiscan. It displays all contract transactions and event details in a human-readable format.
Prepare a file named arg.js
as illustrated below. This file contains the original constructor argument values, in the same order, used while deploying the contract.
module.exports = [
"0x56EC16763Ec62f4EAF9C7Cfa09E29DC557e97006",
"0x186A361FF2361BAbEE9344A2FeC1941d80a7a49C",
"0xf90e66d1452be040ca3a82387bf6ad0c472f29dd"
];
Finally, execute the following command to get the contract verified.
npx hardhat verify --network arbs --constructor-args arg.js <contract_address>