- Collaborative: meant for teams (e.g. traders, investors)
- Token-Gated: only the owners of the Jarvis NFT are granted access
- Pragmatic: can build ready-to-go transactions from the user's intent
- Multi-Agent: combines many agents (potentially an infinite number of agents) to get the most out of AI
Jarvis is powered by:
Browse the deployed Demo App or watch the Ultra-short Explainer Video
- Awesome playground, facilitating pleasant DevEx and easy API calls
- Not clear how to upload the secrets to TEE
- The POST method did not work
- Difficult to troubleshoot and debug the API
- Slow API response times
- No explanations on the response format
- Lack of testnets
- Vague error response messages (e.g. the actual error was the wrong network, but the response was too generic)
- Does NOT work with Metamask
npm i
Include all your secrets in .env
file and add it to .gitignore
npm run build
npm run test
Upload your compiled AI Agent code to IPFS using thirdweb
.
npm run publish-agent
or (if thirdweb fails on you, like it did on us) use CURL
:
curl -F file=@./dist/index.js https://agents.phala.network/ipfs
The command should show the URL to access your AI Agent.
> phat-gpt-template@0.0.1 publish-agent
> phat-fn build --experimentalAsync && tsx scripts/publish.ts
✓ Compiled successfully.
72.73 KB dist/index.js
$$\ $$\ $$\ $$\ $$\
$$ | $$ | \__| $$ | $$ |
$$$$$$\ $$$$$$$\ $$\ $$$$$$\ $$$$$$$ |$$\ $$\ $$\ $$$$$$\ $$$$$$$\
\_$$ _| $$ __$$\ $$ |$$ __$$\ $$ __$$ |$$ | $$ | $$ |$$ __$$\ $$ __$$\
$$ | $$ | $$ |$$ |$$ | \__|$$ / $$ |$$ | $$ | $$ |$$$$$$$$ |$$ | $$ |
$$ |$$\ $$ | $$ |$$ |$$ | $$ | $$ |$$ | $$ | $$ |$$ ____|$$ | $$ |
\$$$$ |$$ | $$ |$$ |$$ | \$$$$$$$ |\$$$$$\$$$$ |\$$$$$$$\ $$$$$$$ |
\____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/
💎 thirdweb v0.14.12 💎
- Uploading file to IPFS. This may take a while depending on file sizes.
✔ Successfully uploaded file to IPFS.
✔ Files stored at the following IPFS URI: ipfs://QmayeZxHXwJxABXaNshP6j8uBE6RedkhmEgiaXd1w1Jib3
✔ Open this link to view your upload: https://bafybeif3y2jpswse2n6s2cikwyjmbak4cxlpm6vrmgobqkgsmmn34l6m4i.ipfs.cf-ipfs.com/
AI Agent Contract deployed at: https://agents.phala.network/ipfs/QmayeZxHXwJxABXaNshP6j8uBE6RedkhmEgiaXd1w1Jib3
Make sure to add your secrets to ensure your AI-Agent works properly.
Once published, your AI Agent will be available at the URL: https://agents.phala.network/ipfs/<your-cid>
. You can get it from the "Publish to IPFS" step.
Test it with curl
.
curl https://agents.phala.network/ipfs/<your-cid>
cd frontend
yarn && yarn dev
By default, all the compiled JS code is visible for anyone to view if they look at IPFS CID. This makes private info like API keys, signer keys, etc. vulnerable to be stolen. To protect devs from leaking keys, we have added a field called secret
in the Request
object. It allows you to store secrets in a vault for your AI Agent to access.
How to Add Secrets
The steps to add a secret
is simple. We will add the Brian API Key in this example by creating a secret JSON object with the brianApiKey
:
{"brianApiKey": "<BRIAN_API_KEY>"}
Then in your frame code, you will be able to access the secret key via req.secret
object:
async function POST(req: Request): Promise<Response> {
const apiKey = req.secret?.apiKey
}
Note: Before continuing, make sure to publish your compiled AI Agent JS code, so you can add secrets to the CID.
Open terminal
Use curl
to POST
your secrets to https://agents.phala.network/vaults
. Replace IPFS_CID
with the CID to the compile JS code in IPFS, and replace <BRIAN_API_KEY>
with your Brian API key. Note that you can name the secret field name something other than brianApiKey
, but you will need to access the key in your index.ts
file with the syntax req.secret?.<your-secret-field-name> as string
The command will look like this:
curl https://agents.phala.network/vaults -H 'Content-Type: application/json' -d '{"cid": "IPFS_CID", "data": {"brianApiKey": "<BRIAN_API_KEY>"}}'
# Output:
# {"token":"e85ae53d2ba4ca8d","key":"e781ef31210e0362","succeed":true}
The API returns a token
and a key
. The key
is the id of your secret. It can be used to specify which secret you are going to pass to your frame. The token
can be used by the developer to access the raw secret. You should never leak the token
.
To verify the secret, run the following command where key
and token
are replaced with the values from adding your secret
to the vault.
curl https://agents.phala.network/vaults/<key>/<token>
Expected output:
{"data":{"brianApiKey":"<BRIAN_API_KEY>"},"succeed":true}
If you are using secrets, make sure that your URL is set in the following syntax where cid
is the IPFS CID of your compiled JS file and key
is the key
from adding secrets to your vault.
https://agents.phala.network/ipfs/<cid>?key=<key>
To help create custom logic, we have an array variable named queries
that can be accessed in the Request
class. To access the queries
array variable chatQuery
value at index 0
, the syntax will look as follows:
const query = req.queries.chatQuery[0] as string;
The example at https://agents.phala.network/ipfs/QmX5ofLpppdaFuuZx3LvGaAZAXz7zuD6gy5AuzE6cyoz4N?key=2e01c25ca431c806&chatQuery=What%20is%20Uniswap will have a value of When did humans land on the moon
. queries
can have any field name, so chatQuery
is just an example of a field name and not a mandatory name, but remember to update your index.ts
file logic to use your expected field name.