-
Create a keypair for the server
npx ucan-key ed --json
Note down
did
andkey
values!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sumUsage = client => { | |
const period = getPeriod(new Date()) | |
/** @type {Record<ProviderDID, Record<SpaceDID, number>>} */ | |
let totalBySpace = {} | |
let total = 0 | |
for (const account of Object.values(client.accounts())) { | |
const subscriptions = await client.capability.subscriptions.list(account.did()) | |
for (const { consumers } of subscriptions.results) { | |
for (const space of consumers) { | |
const report = await client.capability.usage.report(space) |
Want to do an async task of adding two number together? Not problem.
invoke do/async-addition 40, 2
# create a delegation for the result and get the CID
result-cid = cid-for(delegate(do/async-addition-result 40, 2))
# create a receipt for this invocation, including the CID of the result delegation
receipt = generate-receipt-for(do/async-addition 40, 2, fx.join: result-cid)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lassie fetch --dag-scope=entity -providers=/dns4/dag.w3s.link/tcp/443/https/p2p/QmUA9D3H7HeCYsirB3KmPSvZh3dNXMZas6Lwgr4fv1HTTp bafybeicuc7vfbxzaperdc6ng2c4ufeulyjpfrmwuxhxrm6cfdamp5hpw5i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -v -H "Accept: application/vnd.ipld.car;order=dfs" https://dag.w3s.link/ipfs/bafybeibrqc2se2p3k4kfdwg7deigdggamlumemkiggrnqw3edrjosqhvnm --output my.dfs.car | |
... | |
> GET /ipfs/bafybeibrqc2se2p3k4kfdwg7deigdggamlumemkiggrnqw3edrjosqhvnm HTTP/2 | |
> Host: dag.w3s.link | |
> user-agent: curl/7.77.0 | |
> accept: application/vnd.ipld.car;order=dfs | |
> | |
... | |
< HTTP/2 200 | |
< date: Fri, 19 May 2023 14:16:47 GMT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createWriter } from '@ipld/unixfs' | |
import * as CAR from '@web3-storage/upload-client/car' | |
import { create } from '@web3-storage/w3up-client' | |
/** | |
* @param {import('@web3-storage/w3up-client').Client} client | |
* @param {import('@web3-storage/w3up-client/types').FileLike} file | |
*/ | |
async function uploadFile (client, file) { | |
/** @type {import('@web3-storage/upload-client/types').DirectoryEntryLink[]} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CarIndexedReader } from '@ipld/car' | |
import * as pb from '@ipld/dag-pb' | |
import { UnixFS } from 'ipfs-unixfs' | |
// usage: node create-perma-map-fixture sharded-dir.car | |
/** @typedef {{ bitfield: number[], links: Array<Link|Element>, prefix?: string }} Link */ | |
/** @typedef {{ key: string, value: string, prefix: string }} Element */ | |
async function main () { |
Install the new CLI:
npm install -g @web3-storage/w3cli
Create and register new space:
w3 space create SPACENAME
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Goals: | |
// 1. Decouple store from agent | |
// 2. Simplify agent creation | |
// 3. Agent governs data format not store | |
// 4. Initialization of agent, not store | |
// 5. DRY initialization in agent, not repeated in each store impl | |
/** | |
* @param {AgentData} [data] Agent data | |
* @param {object} [options] |
NewerOlder