Skip to content

Commit

Permalink
fix: update "byo agent" example to match website snippet
Browse files Browse the repository at this point in the history
update to match changes from storacha/www#72
  • Loading branch information
travis committed Jan 17, 2024
1 parent 231cf1f commit 71ccf73
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/w3up-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,16 @@ import * as Signer from '@ucanto/principal/ed25519' // Agents on Node should use
import { importDAG } from '@ucanto/core/delegation'
import { CarReader } from '@ipld/car'
import * as Client from '@web3-storage/w3up-client'
import { StoreMemory } from '@web3-storage/w3up-client/stores'

async function main () {
// from "bring your own Agent" example in `Creating a client object" section`
// used command line to generate KEY and PROOF (stored in env variables)
// KEY: `npx ucan-key ed --json` in command line, which returns private key and DID for Agent (the private key is stored in KEY)
// PROOF: w3cli used to run `w3 delegation create <did_from_ucan-key_command_above> --can 'store/add' --can 'upload/add' | base64`, which returns the delegation from Space to the Agent we're using (stored in PROOF)
const principal = Signer.parse(process.env.KEY)
const client = await Client.create({ principal })
const store = new StoreMemory()
const client = await Client.create({ principal, store })

// now give Agent the delegation from the Space
const proof = await parseProof(process.env.PROOF)
Expand Down

0 comments on commit 71ccf73

Please sign in to comment.