Using the Sandbox
The Shade Agent Sandbox is a development workflow that allows you to get up and running with Shade Agents as quickly as possible with minimum prerequisites.
The sandbox template we're using is a simple Shade Agent built with NextJS that acts as a verifiable ETH price oracle. It takes prices from two different APIs, takes the average, and then pushes the price to an Ethereum contract. A pre-deployed Sandbox Template can be found here.
We'll cover two deployment scenarios:
- Local Development: Running the agent locally for rapid testing and development.
- TEE Deployment: Running the worker agent in a real Trusted Execution Environment (TEE).
On the next page, you'll see how to edit this agent for your specific use case.
Prerequisites​
- First,
clone
the template repository.
git clone https://github.com/NearDeFi/shade-agent-sandbox-template shade-agent
cd shade-agent
- Install NEAR and Shade Agent tooling:
# Install the NEAR CLI
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh
# Install the Shade Agent CLI
npm i -g @neardefi/shade-agent-cli
# Install the Phala Cloud CLI
npm install -g phala
If you already have the NEAR CLI installed, check that you have the most recent version
.
- Create a
NEAR testnet account
and record the account name andseed phrase
:
near account create-account sponsor-by-faucet-service <example-name.testnet> autogenerate-new-keypair print-to-terminal network-config testnet create
-
Set up a free Phala Cloud account at https://cloud.phala.network/register then get an API key from https://cloud.phala.network/dashboard/tokens.
What is a Phala Cloud
Phala Cloud is a service that offers secure and private hosting in a TEE using Dstack. Phala Cloud makes it easy to run a TEE, that's why we use it in our template!
This technology has not yet undergone a formal audit. Use at your own risk. Please conduct your own due diligence and exercise caution before integrating or relying on it in production environments.
Local Development​
-
Rename the
.env.development.local.example
file name to.env.development.local
and configure your environment variables. -
Start up Docker:
- Linux
- Mac
sudo systemctl start docker
Simply open the Docker Desktop application or run:
open -a Docker
-
Make sure the
NEXT_PUBLIC_contractId
prefix is set toac.proxy.
followed by your NEAR accountId. -
In one terminal, run the Shade Agent CLI:
shade-agent-cli
The CLI will prompt you to enter your sudo password
.
- In another terminal, start the frontend :
yarn start
TEE Deployment​
-
Change the
NEXT_PUBLIC_contractId
prefix toac.sandbox.
followed by your NEAR accountId. -
Run the Shade Agent CLI
shade-agent-cli
The CLI will prompt you to enter your sudo password
.
This command will take about 5 minutes to complete.
-
Head over to your Phala Cloud dashboard https://cloud.phala.network/dashboard
-
Once the deployment is finished, click on your deployment, then head to the
network tab
and open the endpoint that is running onport 3000
.
Office Hours
Join our weekly 1-on-1, 15 minute sessions for personalized developer support and guidance for Chain Signatures and Shade Agents.
Developer Support Groups
Access async support and connect with other builders in our Telegram Communities.
Reach Out
If your team is building or considering building a production application using Chain Signatures or Shade Agents, please fill our our interest form.