-
Create a keypair for the server
npx ucan-key ed --json
Note down
did
andkey
values! -
Install the w3cli:
npm i -g @web3-storage/w3cli
-
Authorize your agent to use spaces owned by your email address:
w3 authorize [email protected]
-
Create a space for where the uploads will be registered:
w3 space create myspacename w3 space register
-
Delegate from your local machine to the server:
w3 delegation create <did_from_ucan-key_command_above> --can 'store/add' --can 'upload/add' | base64
-
Set up environment variables
KEY
with the output ofkey
from step 1 andPROOF
with the output of step 4. -
In the script, load the agent with the server private key and add the proof of delegation:
import * as Client from '@web3-storage/w3up-client' import { StoreMemory } from '@web3-storage/w3up-client/stores/memory' import * as Proof from '@web3-storage/w3up-client/proof' import { Signer } from '@web3-storage/w3up-client/principal/ed25519' async function main () { // Load client with specific private key const principal = Signer.parse(process.env.KEY) const store = new StoreMemory() const client = await Client.create({ principal, store }) // Add proof that this agent has been delegated capabilities on the space const proof = await Proof.parse(process.env.PROOF) const space = await client.addSpace(proof) await client.setCurrentSpace(space.did()) // READY to go! }
web3-storage/w3up-client#74 should make this a little better. ✅ done